Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Word 97 Mailmerge code - "ActiveDocument.MailMerge.OpenDataSource"

37 views
Skip to first unread message

Mike Collins

unread,
Sep 12, 2001, 3:40:16 PM9/12/01
to
Hi,

I'm trying to change the name of the MailMerge datasource file inside
a Word 97 document by calling
"ActiveDocument.MailMerge.OpenDataSource" during "AutoOpen". But the
Word document is still remembering the name of the datasource file
from last user who amended the document.

This code is exected in AutoOpen. FileName is set to the name of the
Datasource file for this user.....

Sub AutoOpen()

CurrentUser = Environ("Username")
FileName = ".....................\" & CurrentUser & "_word.txt"

ActiveDocument.MailMerge.OpenDataSource _
Name:=FileName, _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:=", PasswordTemplate:=", _
WritePasswordDocument:=", WritePasswordTemplate:=", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:=", SQLStatement:=",
SQLStatement1 _
:="
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = "
.MailSubject = "
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
ActiveWindow.ActivePane.LargeScroll Down:=1
ActiveWindow.ActivePane.LargeScroll Down:=-1

End Sub

Thanks,

Mike Collins,
Weymouth, England.

Peter Jamieson

unread,
Sep 13, 2001, 4:00:21 PM9/13/01
to
Nothing obviously wrong as far as I can see. Just a suggestion and I don't
think it should be necessary, but have you tried using

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ActiveDocument.MailMerge.MainDocumentType = wd<whatevertypeyouwant>

first?

Peter Jamieson
MS Word MVP

"Mike Collins" <mikec...@talk21.com> wrote in message
news:3b9fb9d1...@news.freeuk.net...

Alan Schmidt

unread,
Sep 13, 2001, 5:14:47 PM9/13/01
to
So Word must reestablish the last data source link used before the autoOpen
can be executed? I'm dealing with this issue now also. I'll follow this
thread with interest.
--
Alan Schmidt

Peter Jamieson

unread,
Sep 13, 2001, 6:13:25 PM9/13/01
to
In this case, I was just making an untested suggestion on the assumption
that the existing set-up /might/ interfere with the assignment of a new data
source.

Peter Jamieson
MS Word MVP

"Alan Schmidt" <al...@goconnected.com> wrote in message
news:B7C66FD6.79B1%al...@goconnected.com...

0 new messages