• Can’t record directly into a macro?

    Author
    Topic
    #353663

    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
    
    Viewing 2 reply threads
    Author
    Replies
    • #517899

      I never seem to be able to record the code for clicking the little x at the top right of the window.

      Brooke.

      • #518031

        You just need to bit a little faster. It’s there if you can catch it.

        Sub Macro1()
        '
        ' Macro1 Macro
        ' Macro recorded 03/08/01 by Christopher Greaves
        '
            Application.Quit
        End Sub
        
        • #518072

          For something so hard to trap, you think they’d put more in there!

          Brooke

          • #518196

            You blinked again, didn’t you!!

            You just need to bit a little faster. It’s there if you can catch it.

    • #518081

      Chris,

      It’s been my experience that things which rely on cursor positioning cannot record- unless (sometimes) they can be reprocused by keystrokes.

      I cannot record changing the name of a form field, as this involves a right click on the form field.

      I can record selecting an Excel cell, as this is easily reproducible by keystrokes.

      Or it may be a right click does not record.

      Whatever, it has caused me problems, and added time to solving a problem.

      Microsoft Test (is it still their product?) can reproduce screen positioning and right clicks- it’s a pity W2K cannot.

      • #518197

        I greatly miss the old Windows Recorder. For all that macros couldn’t be edited, it sure was a nifty way of getting SOME things done.

        I wonder what design feature inhibits recording of the r/c. I remember being frustrated in Quattropro years ago …..

        • #518565

          The inability to record the right-click is the same as the inability to record the display of any Word menu or dialog: what’s being recorded is not the menu display per se (and/or any submenus along the way) but rather the Word command or commands that are triggered when you click on the item in the menu (and/or any properties settings that are exposed by the dialog).

          The limitations with recording macros relating to hyperlinks appears to be by design – I recall being unable to do so in Word 97 and recall the same limitation in Word 2000 when I tried. There are of course properties and methods relating to hyperlinks in the Word VBA object model, but many are not recordable. It would be interesting to know why this was left this way….

    • #518101

      I was trying to record something just last night.

      In Word. Tools, Customize, Options Tab.
      Uncheck Standard and formatting share one row.
      Uncheck Menus show recently used.
      Check Show Shortcut Keys in Screentips.

      • #518198

        You’re using Word2000, right? I don’t have those options, but you’re right. I can’t record them in Word97SR2 either.

    Viewing 2 reply threads
    Reply To: Can’t record directly into a macro?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: