Results 1 to 7 of 7
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Linking Word with Access data (XP)

    Microsoft calls this "automation." You create a VBA module in Access that starts up Word, creates a new document, inserts data into it and then... well, then if the user is intended to interact with it, makes it the active window on the screen. There are lots of possible approaches, including creating a nice template in Word that you can use to avoid having to re-invent the formatting every time.

    I suspect there are many samples of this type of project on the Access forum, not so many here.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Linking Word with Access data (XP)

    Access Moderator <!profile=WendellB>WendellB<!/profile> has a tutorial on Automation on his website: Automation 101, with lots of useful links. You may also find his Managing Merges with Access useful.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Linking Word with Access data (XP)

    Hi all,
    Can anyone point me in the right direction please. I have an Access database which contains fields with data in them which I need to create a Word document from when I click a button on the Access form. I am trying to use the "Help" that comes with both Word and Access which has turned out to be less than helpful. One of the main things I am trying to achieve is this. One of the Access fields is a Yes/No field called 'GSTFree'. When this field is clicked (Yes), I want to be able to click a button on the Access form which generates a Word document which displays amongst other things, the words "Your order is GST Free." What is the term for what I am trying to do? Secondly what is the best way to do what I am trying to do? Mail Merge doesn't quite fit into the plans mainly because this project could get big with too
    many fields for Mail Merge to handle. Any advice appreciated.

    Bill

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Linking Word with Access data (XP)

    To add to what Hans and Jefferson have said, Automation is what you want if you want to drive the process from Access, but to be fair it is often a very tedious process. A case in point is the Access thread that begins with <post#=375038>post 375038</post#> - in this case the lounger is trying to automate Outlook instead of Word - but the experience is likely to be similar if your needs are anything more than a few lines of code to generate a simple document. I don't mean to scare you away either - it's a very powerful tool, but it requires understanding the object model of both Word an Access (in this case), and can be a time-consuming task if you have to create a complex document. Good luck with your project, and post if you need guidance.
    Wendell

  5. #5
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Linking Word with Access data (XP)

    Thanks all who replied. I will give your suggestions a go and let you know how I went. Thanks again.

  6. #6
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Linking Word with Access data (XP)

    OK. Thanks all. After researching your advice I now have a clearer understanding of what I need to do. I think my project might fall into the intermediate category in terms of difficulty but I am not too sure. I have created two small files to give me a better idea of what I need and make it easier for any potential helper to assist. The files are zipped and attached to this post. The file names are Automation Test.doc and automationtest.mdb. The Access file has a table and form with only four fields in them. The Access form has a print button on it. The Word Template has text which indicates where to place the text imported from the Access database. One of the fields on the form is a Yes/No field check box.
    When the user clicks on the Print button I want the following to happen:
    1. Automation Test.dot will open.
    2. The details of whatever record in Access is being displayed at the time will be displayed at the appropriate place in the Word document.
    3. If the Yes/No field is checked, I want the text "You have advised us of your tax status." to appear below the other text.
    4. I want the document to print straight away to the default printer.
    I have attached the files to give you a clearer picture of what I am on about.
    Am I going about this problem the right way? FWIW my knowledge of VBA would be considered basic but my knowledge of Access and Word would be intermediate.
    Thanks.

    Bill
    Attached Files Attached Files

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Linking Word with Access data (XP)

    I have attached a zip file with modified versions of the template and database.

    Notes:
    <UL><LI>Before trying it out, you must view the code behind the form, and specify the full path of the template, unless it is in your default Templates folder. Otherwise, Word will not be able to find it.
    <LI>For testing purposes, the filled in document will be displayed on screen. To print directly, change False to True in <code>StartWord "...Automation Test.dot", False</code>.
    <LI>I have set a reference to the Microsoft Word 10.0 Object Library in Tools | References... in the Visual Basic Editor, in order to be able to control Word from Access.[/list]Post back if you have questions.
    Attached Files Attached Files

Posting Permissions

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