View Full Version : Solved: Conditional turn on Track changes
translator_
09-24-2012, 03:31 PM
I have a find/replace macro and it starts with:
ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions
and what it does is turn on Track changes if it is not turned on, and turn it off if it is turned on.
I want a statement that would turn on Track changes if it is not turned on, but leave turned on if it is turned on. Something like:
If Track changes is on
Do nothing
Else
If Track changes is off
Turn it on
End If
fumei
09-24-2012, 04:42 PM
Do you have IntelliSense turned on? If not, you should do so.
If it IS turned on, when you type ActiveDocument.TrackRevisions= IntelliSense with display a popup with True and False. That is because TrackRevisions is Boolean. So...
If ActiveDocument.TrackRevisions = False
ActiveDocukment.TrackRevisions = True
End If
IF TrackRevision is OFF, turn it ON.
The unstated alternative, but logical, result is if it is ON, do nothing (there is no instruction).
translator_
09-25-2012, 01:45 AM
Many thanks. It would throw an error, until I added "Then"
If ActiveDocument.TrackRevisions = False Then
ActiveDocument.TrackRevisions = True
I tried to turn on Intellisense on Notepad++ following these instructions derekreynolds.wordpress.com/2011/09/02/how-to-enable-intellisense-in-notepad but I saw no pop-up.
Can you use Intellisense in Microsoft VBA editor?
fumei
09-25-2012, 02:04 PM
Ooops, doh. Yes I forgot the THEN.
I do not know anything abouyt Notepad++, but yes IntelliSense is in VBA. In the VBE (Visual Basic Editor) go Tools > Options and check Require Variable Declaration.
IntelliSense is very handy because you can shorten a lot of things. Fot example, to have:
ActiveDocument.TrackRevisions = False
inserted in your code you can do type this.
act Ctrl-spacebar downarrow dot tra Ctrl-spacebar = f Tab
Ctrl-spacebar invokes IntelliSense. It is quite good at figuring out what should come next.
act Ctrl-spacebar (likely shows Activate, with ActiveDocument below)
dowbarrow (selects ActiveDocument)
dot (inserts ActiveDocument, and displays the properties of it)
tra Ctrl-spacebar (inserts TrackRevisions)
= (displays True/False popup)
f (selects False)
Tab (accepts False and inserts it)
This is a difference between 39 keystrokes and 12 keystrokes. Once you get used too it, using IntelliSense to enter code is MUCH faster.
translator_
09-25-2012, 03:47 PM
Wow, many thanks! Magic!
fumei
09-25-2012, 10:44 PM
You are welcome. I have always wondered why Microsoft neglected to cover the use of IntelliSense in Help.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.