Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
darren via OfficeKB.com
 
Posts: n/a
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Word Mail Merge feature for custom templates S.Sanghani Mailmerge 3 January 11th 06 10:22 AM
word docs open as mail merge main page-how to reset as a word doc. lyger01 Mailmerge 1 April 21st 05 08:04 AM
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
Mail Merge Issue With Office 97 - Excel Data Source Matt Thorley Mailmerge 1 February 15th 05 11:38 PM
no DDE connection to open data for mail merge LH1844 Mailmerge 1 December 14th 04 10:23 AM


All times are GMT +1. The time now is 12:57 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"