VBA/Excel/Access/Word/Outlook/MailMerge — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:47, 26 мая 2010

Connecting Word with Access and MailMerge

 
Sub MailmergeLetter()
   Dim myLetter As Document
   Documents.Open FileName:="C:\Letter.doc"
   Set myLetter = Documents("Letter.doc")
   myLetter.MailMerge.OpenDataSource Name:="C:\store.mdb", Connection:="TABLE Employees"
End Sub



Merge to a new document and use only records 1 to 3

 
Sub MailmergeLetter()
   Dim myLetter As Document
   Documents.Open FileName:="C:\Letter.doc"
   Set myLetter = Documents("Letter.doc")
   myLetter.MailMerge.OpenDataSource Name:="C:\mydb.mdb", Connection:="TABLE Employees"
         With myLetter.MailMerge
              .Destination = wdSendToNewDocument
            With .DataSource
              .FirstRecord = 1
              .LastRecord = 3
             End With
             .Execute
         End With
End Sub