How to use VBA Code to Clear All on Clipboard?
Have tried answer to
How to Clear Office Clipboard with VBA
But that comes up with error message “User Defined Type not Defined”
I have several Macros in Word utilising clip board.
Recently Copy and Paste stopped functioning, the Copy simply did not register on the Clipboard.
Then a few key strokes later, the Copy feature would return again,
Other times it would return only after operating some other macros.
I found that “Clear Clipboard” was a reliable way of reactivating the Copy function, but can’t find a way to activate via VBA. Some of VBA script on line were incredible complex series of 3 Subs & Functions.
The same could be achieved via Windows: this works as a Shortcut file:
%windir%System32cmd.exe /c “echo off | clip”
OR
This works from Command prompt:
cmd.exe /c “echo off | clip”
I tried to use this routine for opening Word Docs but I did not get it to work on a Shortcut executing a CMD line:
Sub OpenDoc()
Dim strFile As String
strFile = "c:UsersNenadDesktopTest PM.docm" 'change to path of your file
If Dir(strFile) <> "" Then 'First we check if document exists at all at given location
Documents.Open strFile
End If
End Sub
“Documents.Open” doesn’t seem to be relevant because the file is a cmd instruction not a document.
Requests: assistance with any of the above alternatives starting at the top, the most preferred:
- what could be causing Word Copy to Clipboard to fail?
- what is the best way to prevent routines possibly intervene when they are not asked to? There are very few Public Functions and no live Event Functions, I cancelled both of the latter to rule them out as possible causes, so it remains a mystery to me
- Can there be an automated switching off or terminate all background routines when Copy function is activated? and/or
- how to get Clipboard “Clear All” in Macro format, half baked attempts above.
Note that as a VBA novice I won’t understand shortcut answers but am able to copy’n’paste code that works. When the copy function works that is!
Thanks in advance 🙂