Open word from IE breaks mailmerge

D

Damian

Hi I have been trying to open word from IE with asp.net
finnally broke down and had to do it with asp. Well now I
can open it, but when the initial macro runs it cannot
find the mailmerge file CMS.dqy. When I run the template
on the server it works just fine.. I tried even mapping a
drive. Any thoughts? is this possible? here is my macro

Sub Document_Open()
DoMerge
End Sub

Sub DoMerge()

Dim GetUserName As String
GetUserName = Application.UserName
Set DocNew = Documents.Add

ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters
ActiveDocument.MailMerge.OpenDataSource
Name:="O:\CMS.dqy", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, _
SQLStatement:="SELECT * FROM vMailMerge"
ActiveDocument.MailMerge.EditMainDocument
ActiveDocument.MailMerge.Fields.Add
Range:=Selection.Range, Name:="3 Day Letter"
ActiveDocument.MailMerge.Fields.Add
Range:=Selection.Range, Name:=GetUserName
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With

End Sub
 
P

Peter Jamieson

As far as I know you will never be able to do a mailmerge if the .doc is
open within IE - attempts to use many of the properties and methods of the
ActiveDocument.Mailmerge and ActiveDocument.MailMerge.DataSource object will
result in error 4605 "...method or property is not available because the
document is in another application". I think to do the merge, you will at
least have to ensure the .doc opens in a standalone instance of Word. If you
manage that, the data source must either be accessible via a Windows
netwrking path (cf. your mapped drive) or via an ODBC connection string. It
cannot be located at a URL such as http://xyz/cms.dqy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

mailmerge recorded macro 0
Dynamic Subject Line Email Merge 0
Insert variables into mailmerge documents 0
macro stops 0
merge search to long 2
4198 debug 0
Mail Merge Functionality 0
macro 2 issues 0

Top