Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Can I open a word document in excel using a macro?

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Portsmouth.UK
    Posts
    557
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am sure it can be done but can I open a word document from within excel using a macros attached to a button, if so what is the code? Thank you in advance.

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The following should work OK, but you'll need to set a reference to Word in the VBA editor by clicking on Tools-References and checking the Microsoft Word Object Library, if necessary: -

    Dim appWD As Word.Application

    Set appWD = CreateObject("Word.Application")
    appWD.Documents.Open "C:My DocumentsDocument"
    appWD.Visible = True


    Change the path to your document path.

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Posts
    53
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Very good but two problems:

    1) I had to change
    "Dim appWD As Word.Application"
    to
    "Dim appWD As Application"

    2) It always opens a new Word Window weather or not Word is already open and wheather or not the DOC file is already open.

    Anyway to avoid problem 2?

    Thanks,
    Michael

  4. #4
    Board Regular
    Join Date
    Apr 2002
    Posts
    53
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    CORRECTION to:
    1) I had to change
    "Dim appWD As Word.Application"
    to
    "Dim appWD As Application"

    It should have read:
    "I had to eliminate it"

    Thanks,
    Michael

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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