Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2012, 02:34 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Macro recorder and ShowFieldCodes Windows XP Macro recorder and ShowFieldCodes Office 2007
Competent Performer
Macro recorder and ShowFieldCodes
 
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
  #2  
Old 11-04-2012, 01:55 AM
macropod's Avatar
macropod macropod is offline Macro recorder and ShowFieldCodes Windows 7 64bit Macro recorder and ShowFieldCodes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I guess MS programmed the Macro Recorder than way so it didn't have to test the property state and you could use the same code for both actions.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorder and ShowFieldCodes Picture properties bug in Word 2010 Macro Recorder ralphpickering Word VBA 5 10-24-2012 10:15 AM
Macro recorder and ShowFieldCodes Stumped by the recorder again Ulodesk Word VBA 6 07-02-2012 09:23 AM
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft