+ Reply to Thread
Results 1 to 2 of 2

Assign a variable to a word document

  1. #1
    Anson
    Guest

    Assign a variable to a word document

    Hello,

    I have done this before but I lost my notes... How do you assign a variable
    to a Word document when you open it? I thought the following codes would be
    enough but it gives me the "type mismatch" error. Thanks for you help!

    Sub xyz()

    Dim WordApp As Word.Application
    Dim LetterTemplate As Word.Document

    Set WordApp = New Word.Application
    WordApp.Visible = True
    Set LetterTemplate = WordApp.Documents.Open(Filename:="Blah Blah Blah",
    ReadOnly:=True)

    End sub


  2. #2
    Bob Phillips
    Guest

    Re: Assign a variable to a word document

    Anson,

    Your code works fine for me, as long as I use a fully qualified, proper doc
    path.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Anson" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I have done this before but I lost my notes... How do you assign a

    variable
    > to a Word document when you open it? I thought the following codes would

    be
    > enough but it gives me the "type mismatch" error. Thanks for you help!
    >
    > Sub xyz()
    >
    > Dim WordApp As Word.Application
    > Dim LetterTemplate As Word.Document
    >
    > Set WordApp = New Word.Application
    > WordApp.Visible = True
    > Set LetterTemplate = WordApp.Documents.Open(Filename:="Blah Blah Blah",
    > ReadOnly:=True)
    >
    > End sub
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1