D
Dianne Siebold
I have a DLL that opens a template document, creates a data document and then does a mail merge with output going to a new document. In the code below, when it tries to open the file with the merge fields and another user has it open, the user gets a "File In Use" dialog with the buttons Read Only (to open the file in read-only mode), Notify and Cancel. If the user clicks the Read Only button, it opens the file and everything works fine. If the user clicks the Cancel button it goes back to the code and returns error number 4198 "Command Failed."
I have tried using different flags on the Open (ReadOnly:=True) but it always displays the File In Use dialog. Is there a way I can tell if another user has the file open before I open it? I've looked on MSDN but I've only found how to tell if the file is open on the current machine.
Thanks for any assistance.
If mTemplateFile <> "" Then
Set mWord = CreateObject("Word.Application")
mWord.Visible = True
Set mWordMergeDoc = mWord.Documents.Open(mTemplateFile) <== shows the File In Use dialog
DoEvents
mWordMergeDoc.Select
I have tried using different flags on the Open (ReadOnly:=True) but it always displays the File In Use dialog. Is there a way I can tell if another user has the file open before I open it? I've looked on MSDN but I've only found how to tell if the file is open on the current machine.
Thanks for any assistance.
If mTemplateFile <> "" Then
Set mWord = CreateObject("Word.Application")
mWord.Visible = True
Set mWordMergeDoc = mWord.Documents.Open(mTemplateFile) <== shows the File In Use dialog
DoEvents
mWordMergeDoc.Select