Function MergeIt() Dim objWord As Word.Document Set objWord = GetObject("C:\Database\labels.doc", "Word.Document") ' Make Word visible. objWord.Application.Visible = True ' Set the mail merge data source as the Northwind database. objWord.MailMerge.OpenDataSource _ Name:="C:\Database\MyDatabase.mdb", _ LinkToSource:=True, _ Connection:="Query tblCustomers Query", _ SQLStatement:="SELECT * FROM [tblCustomers Query]" objWord.MailMerge.Destination = wdSendToNewDocument objWord.MailMerge.Execute
'The following line must follow the Execute statement because the 'PrintBackground property is available only when a document window i 'active. Without this line of code, the function will end before Word 'can print the merged document.
objWord.Application.Options.PrintBackground = False objWord.Application.ActiveDocument.PrintOut End Function
ביז אין קרעשטמע דארף מען אויך א טרונק בראנפן, וויאזוי געט מען זיך א עצה?
מען קען עס האבן ביי די אידישע וועלט...!
Function MergeIt() Dim objWord As Word.Document Set objWord = GetObject("C:\Database\labels.doc", "Word.Document") ' Make Word visible. objWord.Application.Visible = True ' Set the mail merge data source as the Northwind database. objWord.MailMerge.OpenDataSource _ Name:="C:\Database\MyDatabase.mdb", _ LinkToSource:=True, _ Connection:="Query tblCustomers Query", _ SQLStatement:="SELECT * FROM [tblCustomers Query]" objWord.MailMerge.Destination = wdSendToNewDocument
'The following line must follow the Execute statement because the 'PrintBackground property is available only when a document window i 'active. Without this line of code, the function will end before Word 'can print the merged document.
objWord.Application.Options.PrintBackground = False objWord.Application.ActiveDocument.PrintOut End Function