Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail Merge Word 2000 using vb and excel as datasource

Status
Not open for further replies.

taffey

Programmer
Apr 16, 2007
2
My mail merge is running ver slow when using opendatasource.
Sub Mergeit(strFileName)
'Merge the data from the Excel Spreadsheet to the Active Word Document
Dim objWord
Dim objDoc
Dim datasource As String


Set objWord = CreateObject("Word.Application")
objWord.Visible = True

MsgBox strFileName
'Set objDoc = WordDocuments.Open(strFileName1)

' now open the contract document based on the Selling Resort and the resort
Set objDoc = objWord.Documents.Open(strFileName)

' now get the mailmerge object
'Set wrdMerge = objDoc.MailMerge



With objWord.ActiveDocument.MailMerge

.opendatasource Name:="C:\me\data_Contracts_spi", _
Connection:="Entire Spreadsheet", SQLStatement:="", SQLStatement1:=""


.Destination = wdSendToNewDocument
.MailAsAttachment = True
.SuppressBlankLines = True
'set the record count of the datasource for one record
With .datasource
.FirstRecord = 1
.LastRecord = 1
End With
.Execute Pause:=True
End With

end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top