![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Phil,
As I said, you wouldn't want to use 'Application.DisplayAlerts = False' anyway. As for: Quote:
2. You wouldn't need to - you can use your existing mailmerge main document (which is presumably defined via 'stDocName') if you simply convert it to an ordinary document. Indeed, you can insert mergefields into any document - it just won't function as a mailmerge document unless you do something to cause the document to behave as one. Here's some sample code. I've included a comment with the full range of the 'OpenDataSource' expression's arguments (and a commented-out 'DisplayAlerts = False' line). Code:
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim strMainDocNm As String
Dim strDataDocNm As String
Set wdApp = Word.Application
strMainDocNm = "C:\Users\PhilAJ\Documents\Temp\MailmergeMainDocument.doc"
strDataDocNm = "C:\Temp\abc.txt"
With wdApp
'.DisplayAlerts = False
.Application.Visible = True
Set wdDoc = .Documents.Open(Filename:=strMainDocNm)
With wdDoc
With .MailMerge
.MainDocumentType = wdFormLetters
'OpenDataSource(Name, Format, ConfirmConversions, ReadOnly, LinkToSource, _
AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, _
WritePasswordDocument, WritePasswordTemplate, Connection, _
SQLStatement, SQLStatement1, OpenExclusive, SubType)
.OpenDataSource Name:=strDataDocNm, LinkToSource:=True
.Execute
End With
.Close SaveChanges:=False
End With
End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Thanks very much Macropod - i'll give that a go.
Cheers Phil |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Automating Outlook from Access
|
RMittelman | Outlook | 1 | 02-07-2011 03:11 PM |
| Automating document updates with new text | wordfoolish2 | Word | 0 | 01-04-2011 01:01 PM |
| Automating an address from an Abbreviation | Panzer | Word | 0 | 04-12-2010 06:11 AM |
| Access MailMerge DataSource in VB | advin | Mail Merge | 1 | 01-04-2010 01:34 AM |
| Automating Cel Population of .jpg | skoz55 | Excel | 0 | 01-21-2009 03:43 AM |