[dba-Tech] More on Word Automation

Susan Harkins ssharkins at setel.com
Thu May 10 12:59:34 CDT 2007


Foot... 

Private Sub cmdPrint_Click()
  'Print customer slip for current customer.
  Dim appWord As Word.Application
  Dim doc As Word.Document
  On Error Resume Next
  Err.Clear
  Set appWord = GetObject(, "Word.Application")
  If Err.Number <> 0 Then
    Set appWord = New Word.Application
  End If
  Set doc = appWord.Documents.Open("C:\WordForms\CustomerSlip.doc", , True)
  With doc
    .FormFields("fldCustomerID").Result = Me!CustomerID
    .FormFields("fldCompanyName").Result = Me!CompanyName
    .FormFields("fldContactName").Result = Me!ContactName
    .FormFields("fldContactTitle").Result = Me!ContactTitle
    .FormFields("fldAddress").Result = Me!Address
    .FormFields("fldCity").Result = Me!City
    .FormFields("fldRegion").Result = Me!Region
    .FormFields("fldPostalCode").Result = Me!PostalCode
    .FormFields("fldCountry").Result = Me!Country
    .FormFields("fldPhone").Result = Me!Phone
    .FormFields("fldFax").Result = Me!Fax
    .Visible = True
    .Activate
  End With
  Set doc = Nothing
  Set appWord = Nothing
  Exit Sub

errHandler:
  MsgBox Err.Number & ": " & Err.Description
End Sub

 


I'm using the following procedure to copy Access data to a Word form -- it's
incredible simple. I'm wondering if there's a way to use this process to
fill multiple forms instead of using the merge feature? 

Susan H. 





More information about the dba-Tech mailing list