Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28

    Unanswered: Enter Values in Word File

    Hi Everyone,

    I have a major issue . I need to be able to click on a button in an Access form that will:
    1- open an existing word file (location can be a file on the user's computer)
    2- enter values from the form into a blank table
    3- Save As the document onto the user's desktop
    4- and finally email the document to a specified email address.

    Is this possible with Access?

    All I know is how to open an existing word document :

    Shell "winword ""c:\test.doc"""

    I would really appreciate your help!!

    Thanks,

    Randa

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You need to use Automation (OLE for Process Control - Wikipedia, the free encyclopedia) to launch and control MS-Word from within Access (ACC: How to Open and Close Word Documents with OLE Automation).

    To be able to have your Access project to interact with MS-Word, you'll need to know the MS-Word object model: How to Automate Microsoft Word by using Visual Basic to create a new document
    Have a nice day!

  3. #3
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    Thanks! I may have further questions but this is pretty comprehensive

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

  5. #5
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    Hi Sinddho!

    Ok, I'm back with my question.

    I wrote the following code to open an existing word document and make changes to it (Document name is Budget Scope):

    Dim oWord As Object
    Set oWord = CreateObject("Word.Basic")
    oWord.FileOpen "C:\Users\ralameh\Documents\Proposal Format\Budget Scope.doc"

    oWord.AppShow
    oWord.Bookmarks("Country").Range.Text = Me.Country.Value

    I got an error saying object doesn't support this property or method. I even replaced Me.Country.Value with "Hi" but it still didn't work.

    Any suggestions?

    Thanks!!!

  6. #6
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    Ok, I figured it out by myself again . Or actually copied it from someone online. Thanks Anyway

    Dim objWordApp As Object
    Dim objWordDoc As Object

    'Get pointer to Word Object
    Set objWordApp = CreateObject("Word.Application")

    'Open the document
    Set objWordDoc = objWordApp.Documents.Open("C:\Users\ralameh\Docume nts\Proposal Format\Budget Scope.doc")

    'Make Word Instance visible
    objWordApp.Visible = True
    objWordDoc.Bookmarks("Country").Range.Text = Me.Country.Value

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    That's what I was talking about: you need to know the object model of the target application.
    Have a nice day!

Posting Permissions

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