Results 1 to 3 of 3

Thread: VBA and Word

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I want to run microsoft word, open a document and run a macro from the command line. I can run word and open a document no trouble using the following in the run command from my stat menu.

    "C:\Program Files\Microsoft Office\Office\WINWORD.EXE" c:\1.doc

    but how do I attach a macro command on the end so it will run automatically when word opens. I ONLY want the macro to run when it is opened in this method not when the document is opened in the normal way for editing.


    Things I do when I am bored: DotNetable

  2. #2
    Addicted Member
    Join Date
    Oct 2000
    Location
    Vienna/Austria
    Posts
    132
    Hi davidrobin !!!

    look at

    http://support.microsoft.com/support...-US&SD=gn&FR=0

    there you find the startup commands.

    If the macro starts also if you open the word document
    at you "normal way" then check out the events

    DOCUMENT_OPEN or
    AUTO_OPEN

    in the vba Editor of this document.

    -cu TheOnly

  3. #3
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    We use this all the time. We just take another aproach to this than the previous answer.

    We make a template of the document. Then you can use the Document_New event. This will only execute when you open it like your demonstartion and tuns the macro.

    When opening the document it looks for the Document_Open event wich is not here. The only problem is saving the file. It wants to make a Doc file of it and with another name then the original. Ofcourse it's possible to bypass this by using the document_close event. By setting making an automated saving routine, all you want is there.
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width