Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Open mail merge doc as read only
Hi
Totally new to word vba, I have put together the following code in Access but wish the word doc to opened as read only to protect the original text. Function fnMergeIt(strDoc As String, strTbl As String) Dim objWord As Word.Document Dim strConnection As String Dim path As String Dim strDataDir As String strConnection = "DSN=MS Access Database;DBQ=" & CurrentProject.FullName & " ;FIL=MS Access;" strDoc = Chr$(34) & CurrentProject.path & "\" & strDoc & Chr$(34) Set objWord = GetObject(strDoc, "Word.Document") ' Set the mail merge data source objWord.MailMerge.OpenDataSource _ Name:=CurrentProject.FullName, _ LinkToSource:=True, _ Connection:=strConnection, _ ReadOnly:=True, _ SQLStatement:="SELECT * FROM [" & strTbl & "]" objWord.MailMerge.ViewMailMergeFieldCodes = False ' Make Word visible. objWord.Application.Visible = True Set objWord = Nothing End Function Thanks -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...merge/200604/1 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using Word Mail Merge feature for custom templates | Mailmerge | |||
word docs open as mail merge main page-how to reset as a word doc. | Mailmerge | |||
mail merge with attachments | Mailmerge | |||
Mail Merge Issue With Office 97 - Excel Data Source | Mailmerge | |||
no DDE connection to open data for mail merge | Mailmerge |