View Single Post
 
Old 11-03-2012, 02:34 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Windows XP Office 2007
Competent Performer
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default Macro recorder and ShowFieldCodes

I wanted to write a macro to turn off the ShowFieldCodes setting, which somehow got changed. I used the macro recorder to capture the code for turning it on and off. One macro below turned it on and one turned it off. Oddly, they both have the exact same code. Is this a toggle?

Code:
Sub Macro1()
  ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
End Sub
 
Sub Macro2()
  ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
End Sub
I then did a search on this control and found an MSDN article showing that it takes a boolean argument.

http://tinyurl.com/bxprt6b

So, I added this code to my macro, which seems to work.

Code:
  ActiveWindow.View.ShowFieldCodes = False
My questions is, "Why does the macro recorder return the toggle option rather than the explicit settiong?". It did the same thing for TrackRevisions.
Reply With Quote