Running a Word Macro inside a VB Application

I want to have a command button in my vb application, where i click on it and it opens up a common dialog box thats ok. The file i have selected in the cd box, is the file i want opened in Word and then run my macro on this.

How do I do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jonnygrantAuthor Commented:
Adjusted points to 100
Shell "C:\Program Files\Microsoft Office\Office\WINWORD.EXE /mymacro", 1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
'use word object to run open a word doc and run a macro
'in references, make reference to word object

'<<<<  code for event opening word object and running macro >>>>
    Dim strInput As String     '<<<<  variable for macro name
    strInput = lstMacro.Text   '<<<<  in this example the name is pulled
                               '<<<<  from a list box (listbox text)

          Dim oWord As Object
          Set oWord = New Word.Application

          oWord.Visible = True   '<<<< make word visible (not needed unless you need visible)
      oWord.Documents.Open "c:\Your directory\Your SubDirectory\Your file.doc"
      oWord.Run strInput     '<<<< run your macro
     End If

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.