Hyperlink to Run a Macro

Discussion in 'Microsoft Word Document Management' started by WordWorker, Aug 4, 2009.

  1. WordWorker

    WordWorker Guest

    Is it possible to have a hyperlink run a macro?

    If yes, how?

    If no, suggest this capability be added to the next version of Word (and
    Access, Excel, PowerPoint, et al).
     
    WordWorker, Aug 4, 2009
    #1
    1. Advertisements

  2. WordWorker

    Greg Maxey Guest

    AFAIK, no.

    Have you cosidered a macrobutton field?

    {MarcoButton ThisMacro "Click to run this macro"}

    The field braces are entered using CTL+F9

    ThisMacro is the name of the macro in the current project that you want to
    run.

    Toggle the field code and double click to run.



    WordWorker wrote:
    > Is it possible to have a hyperlink run a macro?
    >
    > If yes, how?
    >
    > If no, suggest this capability be added to the next version of Word
    > (and Access, Excel, PowerPoint, et al).


    --
    Greg Maxey - Word MVP

    My web site http://gregmaxey.mvps.org
    Word MVP web site http://word.mvps.org
     
    Greg Maxey, Aug 4, 2009
    #2
    1. Advertisements

  3. WordWorker

    WordWorker Guest

    Greg,

    I don't quite understand. (I'm not a macro or VBA programmer; I just sort
    of stumble around with mostly macros by example and some simple
    manipulations.)

    Without giving a whole macro course, can you expand a bit on how to do what
    you are talking about and how it works? Will it work in Word 2007? Will it
    work in a locked doc?

    WordWorker


    "Greg Maxey" wrote:

    > AFAIK, no.
    >
    > Have you cosidered a macrobutton field?
    >
    > {MarcoButton ThisMacro "Click to run this macro"}
    >
    > The field braces are entered using CTL+F9
    >
    > ThisMacro is the name of the macro in the current project that you want to
    > run.
    >
    > Toggle the field code and double click to run.
    >
    >
    >
    > WordWorker wrote:
    > > Is it possible to have a hyperlink run a macro?
    > >
    > > If yes, how?
    > >
    > > If no, suggest this capability be added to the next version of Word
    > > (and Access, Excel, PowerPoint, et al).

    >
    > --
    > Greg Maxey - Word MVP
    >
    > My web site http://gregmaxey.mvps.org
    > Word MVP web site http://word.mvps.org
    >
    >
    >
    >
     
    WordWorker, Aug 5, 2009
    #3
  4. WordWorker

    Greg Maxey Guest

    WordWorker,

    I have had no formal training myself so my use of technical terms may be a
    little offbase.

    A macro is a procedure stored in document project (either the ThisDocument
    object or separate module)

    Open the document. Open the VB Editor (VBE) using Alt+F11. If not
    displayed, display the Project Explorer pane (CTRL+R).

    In the explore pane click to expand the project. Insert the following code
    in the "ThisDocument" object:

    Sub ExampleMacro()
    MsgBox "The example macro just executed"
    End Sub

    Close the editor.

    In the document place the cursor where the link should appear and press
    CTRL+F9

    In the field braces that appear { } type in MacroButton ExampleMacro "Dbl
    click to run macro"

    Right click the field and toggle field codes.

    Yes it works in Word2007 and yes it works in protected forms.



    WordWorker wrote:
    > Greg,
    >
    > I don't quite understand. (I'm not a macro or VBA programmer; I just
    > sort of stumble around with mostly macros by example and some simple
    > manipulations.)
    >
    > Without giving a whole macro course, can you expand a bit on how to
    > do what you are talking about and how it works? Will it work in Word
    > 2007? Will it work in a locked doc?
    >
    > WordWorker
    >
    >
    > "Greg Maxey" wrote:
    >
    >> AFAIK, no.
    >>
    >> Have you cosidered a macrobutton field?
    >>
    >> {MarcoButton ThisMacro "Click to run this macro"}
    >>
    >> The field braces are entered using CTL+F9
    >>
    >> ThisMacro is the name of the macro in the current project that you
    >> want to run.
    >>
    >> Toggle the field code and double click to run.
    >>
    >>
    >>
    >> WordWorker wrote:
    >>> Is it possible to have a hyperlink run a macro?
    >>>
    >>> If yes, how?
    >>>
    >>> If no, suggest this capability be added to the next version of Word
    >>> (and Access, Excel, PowerPoint, et al).

    >>
    >> --
    >> Greg Maxey - Word MVP
    >>
    >> My web site http://gregmaxey.mvps.org
    >> Word MVP web site http://word.mvps.org


    --
    Greg Maxey - Word MVP

    My web site http://gregmaxey.mvps.org
    Word MVP web site http://word.mvps.org
     
    Greg Maxey, Aug 5, 2009
    #4
  5. WordWorker

    WordWorker Guest

    It Works! You may have just solved a major problem I am having with a locked
    document. It was the "toggle field" that threw the whole thing off for me
    because I didn't know about it. I turned field codes off differently, but
    your way is much handier. Thank you so very much, Greg.

    "Greg Maxey" wrote:

    > WordWorker,
    >
    > I have had no formal training myself so my use of technical terms may be a
    > little offbase.
    >
    > A macro is a procedure stored in document project (either the ThisDocument
    > object or separate module)
    >
    > Open the document. Open the VB Editor (VBE) using Alt+F11. If not
    > displayed, display the Project Explorer pane (CTRL+R).
    >
    > In the explore pane click to expand the project. Insert the following code
    > in the "ThisDocument" object:
    >
    > Sub ExampleMacro()
    > MsgBox "The example macro just executed"
    > End Sub
    >
    > Close the editor.
    >
    > In the document place the cursor where the link should appear and press
    > CTRL+F9
    >
    > In the field braces that appear { } type in MacroButton ExampleMacro "Dbl
    > click to run macro"
    >
    > Right click the field and toggle field codes.
    >
    > Yes it works in Word2007 and yes it works in protected forms.
    >
    >
    >
    > WordWorker wrote:
    > > Greg,
    > >
    > > I don't quite understand. (I'm not a macro or VBA programmer; I just
    > > sort of stumble around with mostly macros by example and some simple
    > > manipulations.)
    > >
    > > Without giving a whole macro course, can you expand a bit on how to
    > > do what you are talking about and how it works? Will it work in Word
    > > 2007? Will it work in a locked doc?
    > >
    > > WordWorker
    > >
    > >
    > > "Greg Maxey" wrote:
    > >
    > >> AFAIK, no.
    > >>
    > >> Have you cosidered a macrobutton field?
    > >>
    > >> {MarcoButton ThisMacro "Click to run this macro"}
    > >>
    > >> The field braces are entered using CTL+F9
    > >>
    > >> ThisMacro is the name of the macro in the current project that you
    > >> want to run.
    > >>
    > >> Toggle the field code and double click to run.
    > >>
    > >>
    > >>
    > >> WordWorker wrote:
    > >>> Is it possible to have a hyperlink run a macro?
    > >>>
    > >>> If yes, how?
    > >>>
    > >>> If no, suggest this capability be added to the next version of Word
    > >>> (and Access, Excel, PowerPoint, et al).
    > >>
    > >> --
    > >> Greg Maxey - Word MVP
    > >>
    > >> My web site http://gregmaxey.mvps.org
    > >> Word MVP web site http://word.mvps.org

    >
    > --
    > Greg Maxey - Word MVP
    >
    > My web site http://gregmaxey.mvps.org
    > Word MVP web site http://word.mvps.org
    >
    >
    >
    >
     
    WordWorker, Aug 5, 2009
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Williams
    Replies:
    3
    Views:
    609
    Suzanne S. Barnhill
    Jun 19, 2004
  2. Guest

    Word: I create a hyperlink to a pdf. I ctrl-click on hyperlink, .

    Guest, Feb 18, 2005, in forum: Microsoft Word Document Management
    Replies:
    0
    Views:
    426
    Guest
    Feb 18, 2005
  3. Guest

    Convert Word hyperlink with bookmark to PDf hyperlink

    Guest, Mar 29, 2005, in forum: Microsoft Word Document Management
    Replies:
    3
    Views:
    824
    Jezebel
    Mar 30, 2005
  4. Guest

    Mass change hyperlink strings, or use a variable in the hyperlink?

    Guest, Aug 5, 2006, in forum: Microsoft Word Document Management
    Replies:
    4
    Views:
    575
    Jezebel
    Aug 6, 2006
  5. Guest

    word hyperlink appears when turning on the hyperlink

    Guest, Dec 26, 2006, in forum: Microsoft Word Document Management
    Replies:
    2
    Views:
    376
    Guest
    Dec 26, 2006
Loading...

Share This Page