It’s a favorite technique of mine to record a macro in order to see the sort of thing that I need to do in Word97/VBA. I agree with those who tell me it produces wretched code (try recording “View, header”, for example) but it speeds up the process of my finding out a key part of some operation.
So this morning, after r/c on a hyperlink and choosing Hyperlink, Edit Hyperlink, Remove Link from the ensuing dialogue, I bestirred myself to record a macro.
What a surprise! I couldn’t record a macro!
Well, I could, but I couldn’t record the r/c, let alone the pop-up menu.
Undeterred I set the text cursor up ahead, started recording again, Ctrl-RightArrowed my way to the blue hyperlink, and from Word’s main menu found Insert, Hyperlink (uh-oh, here comes a hyperlink on a hyperlink?) and removed the link that way.
The recorded code is set out below.
FWIW commenting out the two MOVE statements and navigating by hand prior to calling is just as effective; so presumably I have the makings of an “Unlink-all-hyperlinks” macro on my hands here.
Question: Have you ever found things you can do regularly but can’t record directly into a macro?
Sub Macro1() ' ' Macro1 Macro ' Macro recorded 03/07/01 by Christopher Greaves ' Selection.MoveRight Unit:=wdWord, Count:=6 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.Range.Hyperlinks(1).Delete End Sub