Results 1 to 4 of 4
  1. #1
    Bill H is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    1

    Create new Word document.

    I have an Access database that I use for document control. I would like to be able to fill out a form in the database, and have it open a document template, and automatically enter certain information, such as a document number, and author. Is there a way to do this?


    Thank you for your time and assistance.
    Bill H.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Sounds like a mail merge operation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    Bill,

    there is a very easy way you can make microsoft office teach you what is what, in terms of coding a visual basic operation inside the software suite. record a macro in your target app and copy the code directly into your source app. usually you don't have to replace many of the qualifying statements (e.g. - the object in the code) other than those that are directly related to the target application on the top level. for instance, in the case of word, a document object or the app object itself.

    below is PSEUDO code (probably not perfectly correct) that shows how to do this. ask word to tell you how to code a basic app...opening a new template:

    Code:
    Documents.Open FileName:="Doc2.dotx", ConfirmConversions:=False, ReadOnly _
        :=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
        :="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
        , Format:=wdOpenFormatAuto, XMLTransform:=""
    so in your source app, other than creating the instance of the target app and replacing the qualifiers, things should stay exactly the same:

    Code:
    Dim wd As Object
    Dim wt As Word.Document
    
    
    Set wd = CreateObject("word.application")
        wd.Visible = True
    
    
    Set wt = wd.Documents.Open(Filename:="path")
    More than likely, as in this example, almost all of the code written by the target app itself could be duplicated by the source app just by adding the prefix wd. to it.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I don't work with Word at the vba level -- just use it as word processor.
    However, I did a few searches after reading help_me_with_access post.

    These links may give you some additional/contextual info or ideas to go with the previous post #3-

    http://www.fontstuff.com/vba/vbatut09a.htm
    http://www.techrepublic.com/blog/mso...ccess-data/164
    http://www.functionx.com/word/Lesson06.htm
    http://www.functionx.com/word/Lesson...m/chap11b.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Embed word document into form
    By jgelpi16 in forum Forms
    Replies: 4
    Last Post: 06-26-2012, 11:31 AM
  2. Replies: 8
    Last Post: 04-05-2012, 03:09 PM
  3. Import Word document using VBA
    By degras in forum Import/Export Data
    Replies: 4
    Last Post: 04-12-2011, 02:40 AM
  4. Replies: 5
    Last Post: 07-16-2010, 10:12 AM
  5. Word document INTO Access form
    By jonathonhicks in forum Forms
    Replies: 0
    Last Post: 04-30-2007, 05:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums