Insert Cross Reference Macro and Dialog Box

Posted on 2005-05-17
Last Modified: 2008-02-01
I wrote a mini macro as follows:

Sub InsertXRef()
    Application.Run MacroName:="InsertCrossReference"
    Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Font.Bold = wdToggle
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.Style = ActiveDocument.Styles("Default Paragraph Font")
End Sub

It merely shows the cross-reference dialog and makes the inserted cross reference bold.

However, I can't get the box that says "Insert As Hyperlink" to stay checked when I run the macro.

If I click Insert, Cross Reference, the box is checked.
If I click Alt F8 and run the Insert Cross Reference macro, the box is checked.

But if I click my toolbar button that runs the above macro, the box is unchecked.
If I run the following line of code, the box is unchecked.

I can't figure out a way to keep that option checked - we always want to insert the cross reference as a hyperlink.  I've never run across this before so I need your help.

Thanks in advance!

Question by:Joanne M. Orzech
    1 Comment
    LVL 37

    Accepted Solution

    Oh - I found my own answer:

       With Dialogs(wdDialogInsertCrossReference)
          SendKeys "%th"
          SendKeys "{enter}"
          SendKeys "%p"
          SendKeys "{enter}"
          SendKeys "%h"
       End With;en-us;209668


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
    This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
    This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
    This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now