Terri Jarus
jarus at amerinet-gpo.com
Wed Jul 7 11:54:09 CDT 2004
I have set up Word Automation to create a really nice document that is created from pushing the button on a form. That, of course, creates the Word doc for the current record. Now I have a form that pulls back a select grouping of records based on a date and I want to send them to the same Word document. So I would have a continuous document moving through each record. I've tried Do...While, but I'm not getting it set up correctly. I get a type mismatch error on "Me.Recordset". Thanks for any help or suggestions. A sample of my code follows: Private Sub cmdAnnounce_Click() Dim objWord As Word.Application Dim filename As String Dim rst As Recordset Set rst = Me.Recordset Set objWord = New Word.Application filename = "U:\Suppliers\Reports\Contract Sales\EForm\ContInfoNEW\mktg_announce.dot" If Not (rst.BOF And rst.EOF) Then rst.MoveFirst Do With objWord On Error GoTo MsgInfo .Visible = True .Documents.Add _ Template:=filename, _ NewTemplate:=False .Selection.GoTo _ What:=wdGoToBookmark, _ Name:="SupplierName" .Selection.TypeText _ Text:=SupplierPrintName .Selection.GoTo _ What:=wdGoToBookmark, _ Name:="ContractNumber" .Selection.TypeText _ Text:=ContractNumber .Selection.GoTo _ What:=wdGoToBookmark, _ Name:="PDU" .Selection.TypeText _ Text:=Prog objWord.Selection.TypeParagraph objWord.Selection.MoveDown Unit:=wdLine .Quit End With rst.MoveNext Loop End If rst.Close Set objWord = Nothing MsgInfo: On Error Resume Next 'MsgBox "There is a required field missing information, please recheck your CDS data. Enter any required data into the Contract Info database." Exit Sub End Sub Terri Jarus Director, Contract Support Services jarus at amerinet-gpo.com 314-542-1902 --------------------------------------------------------------------------- This email and any files transmitted with it are confidential and intended solely for the use of the individuals or entities to whom they are addressed. If you have received this email in error please return it to the sender, and erase any copies thereof. Copyright 2004 Amerinet 1nc.