MS 365 Word VBA Macro
Copies table at beginning of macro for use later, then changes original table for desired output.
Several sub-routines later, it copies the table from the clipboard.
Prior to MS365, this worked without an issue.
Now, we get Run-time error 4605, This method or property is not available because the Clipboard is empty or not valid.
When we debug the error and press the F8 key, the contents of the Clipboard paste without a problem. If we click the run button on the error, the macro pastes the contents and continues with operation until the copied table is required again, at which time the same error occurs. Same result. F8 and run both proceed to copy the contents and continue operation.
Tried changing to Selection.PasteSpecial. Same result.
Tried clearing the clipboard. Same result.
Tried turning off clipboard history. Same result.
Tried turning off smart copy paste option. Same result.
Tried various options with Selection.PasteSpecial using various DataTypes. None worked or we got the same result.
We can manually paste the contents from the clipboard at that same place in the code (after ending the code).
What's strange is the debug mode will paste the contents, but the run-time will not.
Here is what copies the table:
DOCNAME1.Tables(1).Select DOCNAME1.Tables(1).AutoFitBehavior wdAutoFitFixed Selection.HomeKey Unit:=wdStory, Extend:=wdMove Selection.WholeStory Selection.Copy
And, also used the range method... was able to get all three to copy the table to the Clipboard, but none changed the manner in which it is pasted.
Code for pasting is simply:
or the original:
Any thoughts? Ideas? Please help.