Unaccounted change in new document

DickyP

Active member
Local time
Today, 07:55
Joined
Apr 2, 2024
Messages
520
I have a Word template that creates and fills several weeks of food menus. It has been working without problem in the same manner unchanged since 2017, until this week when it has suddenly started to throw up an error - "Command not available" on the VBA line "Selection.paste".

Does anyone know of any changes in Office/Word/VBA which might have called this? Or any other ideas?
 
Go to Settings >> Update and look for "Update History" to see if you've had an Office update. By any chance, are you using Office 365? They do sneaky updates sometimes. I don't know if you can roll back a patch for O365, though, since I don't have that product.
 
Cut/Copy/Paste more than likely are unchanged.
But what could have happened is that the clipboard was in use by another app. Reboot the machine, don't start anything else, and try again.

Another test you could perform is to do the operation manually. Is "Paste" grayed out when you get to that point?
 
Copy and paste are definitely working differently when I select and copy a table, which now copies no formatting.

The template/ macros still work perfectly in Word 2003 on my laptop.

I am actually redesigning the template to do things differently (and if truth were told better!)
 
After a lot more investigation I have confirmed that cut & paste in Word *has* changed.

I have a number of Word routines in both Word itself or using the Word object model from Acceee, where the template has a table which I copy, then after filing it move to the end of the document to new page paste the saved table and fill, and repeat for as many times as necessary.

All of these have ceased to work, despite being unchanged for years and all working perfectly until I used one last week.

Don't ask me how and I have developed a different work flow for one and will do the others as I need.
 
In case anyone is actually interested (possibly/probably unlikely), Word Cut & Paste has changed. You now have to be much more specific.

What used work in my scenario;
- Tables(1).Select
- Selection.save

and then later move to the end of the document and then paste

- Selection.EndKey Unit:=wdStory
- Selction.Paste

Now has to be:

Selection.WholeStory ' eg, entire document as copying the table doesn't copy formatting and bookmarks.
Selection.Copy

then when you move to the end of the document

- Selection.PasteAndFormat wdFormatOriginalFormatting

As you can imagine fun to find out what wasn't working.
 
What used work in my scenario;
- Tables(1).Select
- Selection.save
I'm slightly confused...
The Selection object does not have a .Save method.
With the limited fragments you provided of your original code, I don't see any code copying anything into the Selection object.
Under these circumstances a "Command not available" error doesn't seem entirely unreasonable.
 
I'm slightly confused...
The Selection object does not have a .Save method.
With the limited fragments you provided of your original code, I don't see any code copying anything into the Selection object.
Under these circumstances a "Command not available" error doesn't seem entirely unreasonable.
It's actually Application.Selection and it saves the Table that been selected. Within VBA in Word it is by definition the Application object if used without without a qualifier (or was).

Application.Selection is actually the cursor position.

And the code (without Application) is what is generated by the 'Record a Macro' facility.
 
It's actually Application.Selection and it saves the Table that been selected.
Selection.save does not save anything. I raises an "Method or data member not found" compile error.
As it is an compile error, I suspect that this line is not actually in your real code but you made this error just in the post here.
 
Selection.save does not save anything. I raises an "Method or data member not found" compile error.
As it is an compile error, I suspect that this line is not actually in your real code but you made this error just in the post here.
You're right, of course - should be Selection.Copy :)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom