C
Curt
Have the following macro prints fine closes print screen ok
issues
prints a last page with fields used in letter something in code must be
telling it to print fields. I do notice that every thing for fields is listed
both in text and query?
next after closeing print window will not close word have to click close.
Got me
Here is my code hopeing am not asking to much
Thanks
Macro recorded 6-Oct-08 by Curtiss A. Greer
'
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="C:\Parade\Parade.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"DSN=Excel
Files;DBQ=C:\Parade\Parade.xls;DriverId=790;MaxBufferSize=2048;PageTimeout=5;" _
, SQLStatement:="SELECT * FROM `MailE$`", SQLStatement1:=""
ActiveDocument.MailMerge.EditMainDocument
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Entry"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Contact_Person"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Address"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"CityState"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Zip_"
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Dear: "
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Contact_Person"
ActiveDocument.MailMerge.datasource.QueryString = _
"SELECT * FROM `MailE$` WHERE ((` Entry` IS NOT NULL ) AND (`Contact
Person` IS NOT NULL ) AND (` Address` IS NOT NULL ) AND (`City&State` IS NOT
NULL ) AND (`Zip ` IS NOT NULL ))" _
& ""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .datasource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
ActiveDocument.PrintOut Background:=False
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
If Documents.count >= 0 Then Application.Quit
Application.Quit
' ActiveWindow.Close
' CommandBars("Stop Recording").Visible = False
End Sub
issues
prints a last page with fields used in letter something in code must be
telling it to print fields. I do notice that every thing for fields is listed
both in text and query?
next after closeing print window will not close word have to click close.
Got me
Here is my code hopeing am not asking to much
Thanks
Macro recorded 6-Oct-08 by Curtiss A. Greer
'
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="C:\Parade\Parade.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"DSN=Excel
Files;DBQ=C:\Parade\Parade.xls;DriverId=790;MaxBufferSize=2048;PageTimeout=5;" _
, SQLStatement:="SELECT * FROM `MailE$`", SQLStatement1:=""
ActiveDocument.MailMerge.EditMainDocument
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Entry"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Contact_Person"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Address"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"CityState"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Zip_"
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Dear: "
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Contact_Person"
ActiveDocument.MailMerge.datasource.QueryString = _
"SELECT * FROM `MailE$` WHERE ((` Entry` IS NOT NULL ) AND (`Contact
Person` IS NOT NULL ) AND (` Address` IS NOT NULL ) AND (`City&State` IS NOT
NULL ) AND (`Zip ` IS NOT NULL ))" _
& ""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Destination = wdSendToPrinter
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .datasource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
ActiveDocument.PrintOut Background:=False
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
If Documents.count >= 0 Then Application.Quit
Application.Quit
' ActiveWindow.Close
' CommandBars("Stop Recording").Visible = False
End Sub