How do I launch a Word macro from a desktop shortcut?

July 26, 2012 at 12:55:51
Specs: Windows 7
I created a multi-page form in MS Word 2010. I then drafted a short macro that inserts the date and time into the form and then moves the cursor to the first open field. I want to put a shortcut on my desktop that, when clicked, opens Word, opens the document and runs the short macro. How do I do that?


See More: How do I launch a Word macro from a desktop shortcut?

Report •

July 26, 2012 at 13:09:19
'script of macropener.vbs

Dim Word
Dim WordDoc
Set Word = CreateObject("Word.Application")

' Make Word visible
Word.Visible = True

'Open the Document
Set WordDoc ="c:\replacewithyourname.doc")

'Run the macro
Word.Run "startup_macro_replace_with_your_name"

:: mike

Report •

July 26, 2012 at 13:36:53
Thanks for your reply. Either I don't understand or I don't think that this is what I was looking for. At its simplest, I was hoping to find the macro file and drag-and-drop a copy onto my desktop so that when I click it it would automatically open the document and run the set-up macro. I found the normal.dotm file but can't access individual macros within it. Is there a way to place on my desktop a shortcut to a particular Word macro?

Report •

July 26, 2012 at 13:56:22
Perhaps this will work for you..

In the Visual Basic Editor you will see a ThisDocument module for your Word document.

If you use a Document_Open event macro in that module, the code will run as soon as the document is opened.

The code below presents a MsgBox whenever the document is opened:

Private Sub Document_Open()
  MsgBox "I'm Open!"
End Sub

Perhaps if you replace my instruction with your instructions, you'll get what you want.

All you'll need is a shortcut to the document itself on your desktop.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question