Results 1 to 5 of 5

Thread: how to open a word document when running an excel macro

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71

    how to open a word document when running an excel macro

    I'm using an Excel macro. and I want to run a word macro
    i'm looking for a command like

    call wordmacro
    or
    Application.Run "doc1.doc!texte"

    but those one aren't working

    thanks

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: how to open a word document when running an excel macro

    If you are coding properly, with lots of objects you should be able to reference word then copy the macro code into Excel and use the objects set up. You may need to declare some constants though or replace them in the code.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71

    Re: how to open a word document when running an excel macro

    ???

    didn't understand anything

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71

    Re: how to open a word document when running an excel macro

    you mean something like this
    but it looks like something is not really ok this is very slow

    VB Code:
    1. Sub test()
    2.  
    3. Dim objExcel As Object
    4. Set objExcel = CreateObject("word.Application")
    5. ' Make Excel visible'
    6. objExcel.Visible = True
    7.  
    8. 'Open template'
    9. Dim wb As Object
    10. Set wb = objExcel.documents.Open("F:\dummy.doc")
    11. Set wb = objExcel.Application.Run("F:\dummy.doc!mes")
    12.                
    13. End Sub

  5. #5
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: how to open a word document when running an excel macro

    here are the command line options for Word:

    Code:
    Word Startup Command Line Switches (All Versions)
    
    \winword.exe [/a] [/c] [/ltemplate name] [/n] [/m[macroname]]
    [/t] [/w] [/x] [/regserver] [/unregserver] [filename] [filename]
    
    Switch Meaning
    
    Blank  Starts a new Word window in an existing instance of Word.
    /a     Starts Word without a template (including startup addins) Word 6 only
    Starts Word without a template (including startup addins) or options stored
    inthe registry, Word 95, 97, & 2000. only
    /c     Starts Word and runs Netmeeting. Word 2000 only.
    /l     Load a specific addin Word 95, 97, & 2000 only
    /n     No new default document
    /m     Runs a macro [/mmacroname] or prevent autoexec from running [/m] Word
           6, 95, 97, & 2000.
           Run a macro [/mmacroname] Word 1 & 2 only
           Cannot be used with the /t switch
    /q     [Added in Word 2000 SR1] (quiet start) will suppress the opening
           splash screen.
    
    /r     shorthand for /regserver
    /u     shorthand for /unregserver
           Both work in Word (but not in Excel), i.e. in Word 97 and 2000.
           (MS lists /u as 'no effect' for Word 2000 though.)
    /t     Bases a new document on the specified document Word 95, 97, & 2000.
           Starts the Tutorial Word 1 only
    /w     Without displaying Tip Of The Day Word 6 only
           Starts a new instance of Word. Word 2000 only.
    /x     Starts a new instance of Word that only accepts one DDE conversation.
           Used by the Windows shell for printing. Word 97 & 2000.
    /regserver   Registers Word in the registry. Word 95, 97, & 2000.
    /unregserver Unregisters Word in the registry. Word 95, 97, & 2000.
    Filename     Opens a file
    Filename Filename     Opens multiple files Word 6, 95, 97, & 2000.
    
    The office Startup Application is a small companion program with the
    following command line switches. It also provides services for starting
    Office Help and in 2000 performs a test to see if Auto Repair should run.
    
    Word 97
    
    \osa.exe [/b] [/f] [/n]
    
    Word 2000
    
    \osa9.exe [/b] [/f] [/l] [/n]
    
    Switch Meaning
    
    /b     Initilises OLE and some fonts so OLE programs will start faster. It's
           tuned for office programs and basically puts the OLE libraries into
           the disk cache.
    /f     Displays the Open Office Document dialog box.
    /l     Checks to see if the Office Toolbar should be loaded at startup, and
           if so start the Office Toolbar.
    /n     Displays the New Office Document dialog box.
    
    Examples
    C:\Program Files\Microsoft Office\Office\winword.exe Filename
    C:\Program Files\Microsoft Office\Office\winword.exe Filename Filename
    C:\Program Files\Microsoft Office\Office\winword.exe /a
    C:\Program Files\Microsoft Office\Office\winword.exe /n
    C:\Program Files\Microsoft Office\Office\winword.exe /m
    C:\Program Files\Microsoft Office\Office\winword.exe Filename /mmacroname
    C:\Program Files\Microsoft Office\Office\winword.exe /tDocumentPathAndName
    C:\Program Files\Microsoft Office\Office\winword.exe /t
    C:\Program Files\Microsoft Office\Office\winword.exe /lAddinPathAndName
    C:\Program Files\Microsoft Office\Office\winword.exe Filename /w

    You can "Shell" out with any of these -

    with a little bit of ingenuity and cleverness, I'm sure you can come up with something of greatness !!!

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