Results 1 to 2 of 2
  1. #1
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56

    Word 2007 filling the forms

    Hi,

    I want export data from Access 2007 to word 2007 with legacy forms. I created a simple layout, and i copied the code from this author

    http://www.techrepublic.com/blog/how...tag=rbxccnbtr1

    (the second version to populate all data).

    The point is, access data populates the fields into the word fields, but is not making new pages for each record.

    The only way that i did to create 170 pages with access data, is only when i use the mail merge function.




    Private Sub btnexport2word_Click()
    'Print customer slip for current customer.
    Dim appWord As Word.Application
    Dim doc As Word.Document
    Dim db As Database
    Dim rst As dao.Recordset
    'Avoid error 429, when Word isn't open.
    On Error Resume Next


    Err.Clear
    'Set appWord object variable to running instance of Word.
    Set appWord = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
    'If Word isn't open, create a new instance of Word.
    Set appWord = New Word.Application
    End If
    'Populate recordset object.

    Set rst = CurrentDb.OpenRecordset("SELECT * from warehouse", dbOpenForwardOnly)
    'Cycle through records to fill Word form fields.
    Do While Not rst.EOF
    Set doc = appWord.Documents.Open("E:\ACCESS DATABASE\warehouse.docx", , True)
    With doc
    .FormFields("fldprid").Result = rst!prID
    .FormFields("flddescription").Result = rst!ProductDescription
    .Visible = True
    .Activate
    rst.MoveNext
    End With
    Loop
    Set doc = Nothing
    Set appWord = Nothing
    Exit Sub
    errHandler:
    MsgBox Err.Number & ": " & Err.Description

    End Sub





    Any ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    I have never tried to program interaction between Word and Access but I think mail merge is the only way you can get what you want.
    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.

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

Similar Threads

  1. Replies: 0
    Last Post: 05-17-2012, 09:24 AM
  2. Filling controls on two forms
    By recon2011 in forum Forms
    Replies: 3
    Last Post: 09-01-2011, 01:54 PM
  3. Word Wrap in Access VB (MSAccess 2007)
    By rcrobman in forum Programming
    Replies: 4
    Last Post: 04-26-2011, 03:45 PM
  4. Replies: 13
    Last Post: 01-27-2011, 11:12 AM
  5. is it possible to integrate word to access 2007
    By tintincute in forum Access
    Replies: 7
    Last Post: 09-28-2010, 05:04 AM

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