Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    Huntington, IN
    Posts
    54

    Question Unanswered: Open Word doc from Access using variable

    I can get Access to open Word and a file using:

    Set objDoc = objWord.Documents.Add("c:\Datafiles\Test Case.rft")

    Is there a way to use a variable or a field value such as

    Set objDoc = objWord.Documents.Add([Filename])

    where [Filename] is the field that includes the entire path and filename.

    The above, while logical, does not work.

    Thanks for any help!!

    Matt

  2. #2
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    If you do

    Filename = "c:\Datafiles\Test Case.rft"

    Set objDoc = objWord.Documents.Add(Filename)

    it should work.

    Greetz

  3. #3
    Join Date
    Sep 2004
    Posts
    161
    another way i use :
    Code:
        Set Doc_sortie_HTML = Documents.Add
        Set Doc_sortie_HTML = ActiveDocument
    ......
        FileName = Mid(Nom_fic, 1, InStr(1, Nom_fic, ".") - 1) & ".html"
        Doc_sortie_HTML.SaveAs filename:=FileName, FileFormat:=100
        Doc_sortie_HTML.Close
    FileFormat:=100 Save as html
    Last edited by jepi; 09-23-04 at 08:38.

  4. #4
    Join Date
    Mar 2004
    Location
    Huntington, IN
    Posts
    54

    Smile Thanks

    Thanks! I got it. I had tried:

    Set objDoc = objWord.Documents.Add(FileNameField)

    which didn't work. At your suggestion, I assigned the field value to the variable first, which did work.

    Filename = [FileNameField]
    Set objDoc = objWord.Documents.Add(Filename)

    Thank you. Have a good day.

    Matt

Posting Permissions

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