Ever had one of those forms that repeats someone’s name or some other piece of information, um, repeatedly? Say, a will or a power of attorney or something similar?
If you’ve tried to make yourself a homegrown forms database, knowing that you’ll have to go in each time and fill in the variable information (name, he/she, his/her, son/daughter/children, etc.) in all (and I do mean all) the right places, then you can appreciate this reader’s dilemma:
I defined a macro successfully [to insert “Page” and the page number], with a button on the Quick Access Tool Bar. It works until I log off. After re-entering and trying the macro, I get an error message “Run Time error 5941 The requested member of the collection does not exist.” Any suggestions?
A macro that only runs until you log off. Well, that’s a puzzler.
As I told him in our email exchange, I’ve noticed that in Word 2010, macros are sometimes spotty in picking up settings from actions you take in the Ribbon. (It used to work fine — not sure what’s changed.) I myself had a similar problem with a macro I tried to do for a watermark.
I suspected he was attempting to embed the page number command using Word’s Insert Page Number command from the Header/Footer Tools contextual ribbon menu:
The problem there is the contextual part. I think the macro was freaking out because it didn’t find the Header/Footer Tools menu from which to draw the Insert Page Number command, so it scrambled. (The whole “macro disappears when I log out” thing? I got no clue.)
So I suggested he program the “Insert Page Number” thing into his macro from the Quick Parts menu instead:
For you code jockeys out there, here’s how that works out:
' test Macro
Selection.TypeText Text:="Page "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"PAGE \* Arabic ", PreserveFormatting:=True
Worked perfectly. Thanks again for your help.
Just what I like to hear!
Got a question of your own? Ask it via my Ask the Guru page!