Excel VBA: Show or Hide the Clipboard Task Pane

This Excel VBA macro toggles the Clipboard task pane viewing.

Macro Example

Sub SwitchClipboadPane()

  With Application
    .DisplayClipboardWindow = Not .DisplayClipboardWindow
  End With 

End Sub

Description

Starts the With Structure

Sub...

  With Application

The 3rd line starts the With…End With structure.

This statement tells Excel that any action applies to the Application.

Application

The Application property returns an Application object.

obj-Excel-Global-Application

Show or Hide the Clipboard Task Pane

Sub...

  With Application
    .DisplayClipboardWindow = Not .DisplayClipboardWindow

The 4th line displays or hides the Clipboard task pane.

Application.DisplayClipboardWindow

The Application.DisplayClipboardWindow property returns True if the Clipboard is displayed.

obj-Excel-Application-DisplayClipboardWindow

Not Operator

The Not operator switches a boolean value to its opposite
If the Application.DisplayClipboardWindow property is True, then it will be False.
If the Application.DisplayClipboardWindow property is False, then it will be True.

Ends the With

Sub...

  With Application
    .DisplayClipboardWindow = Not .DisplayClipboardWindow
  End With 

The 5th line ends the With…End With structure.

After the 5th line is evaluated, this macro ends.

Sub SwitchClipboadPane()

  With Application
    .DisplayClipboardWindow = Not .DisplayClipboardWindow
  End With 

End Sub

Properties

http://www.relief.jp/itnote/archives/excel-vba-display-clipboard.php

Apply to

  • Excel 2013
  • Excel 2010
  • Excel 2007