J
JimLad
Hi,
In my application, I open a document, change some values, print, then
exit without saving. This works fine if there are no WINWORD processes
already open. However, if word is already open (with unchanged default
doc) then I get ''Word cannot save this file as it is already open
elsewhere. (Normal.dot)". Is there a setting that I can change to
prevent normal.dot getting changed or alternatively is there any way
of suppressing the message? At the moment the only thing I've managed
to do is make the app sleep for a second so the user has time to close
the prompt before the app crashes - the app then continues fine. But
it's a bit of a rubbish workaround - the user sees the message and has
to take swift action to avoid a crash.
Sorry. I know there are a lot of posts on normal.dot issues, but most
are when closing a document or instance - this is when opening an
instance. I'm not really up on Word automation...
Cheers,
James
Dim wApp As Word.Application
Dim strPath As String
Dim objWord As Word.Document
'Open Word
Try
wApp = New Word.Application ' Message shown when this line
is executed.
Catch ex As Exception
...
End Try
'TODO: This is a workaround for a dialogue box that gets shown
if Word is already open.
'"Word cannot save this file as it is already open elsewhere.
(Normal.dot)"
'This sleep statement gives the user time to close the dialog
box and continue.
'If dialog box is not closed in time then objWord is created
successfully but all properties return {"Call was rejected by callee.
(Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))"}) and the
application will crash when attempting the find and replace.
System.Threading.Thread.Sleep(1000)
Try
'Open separator sheet
objWord = wApp.Documents.Open(strPath, ReadOnly:=True)
Try
'find an replace the fields in the document
objWord.Content.Find.Execute("pclient", False, False,
False, False, False, False, False, True,
CStr(objMember.FilenetClientName), True)
wApp.Visible = False
'print the result
objWord.PrintOut()
MsgBox("Print out has been sent to the default
printer.")
Catch e As Exception
...
Finally
'Close document
objWord.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
objWord = Nothing
End Try
Catch e As Exception
...
Finally
'close word
'CType to _Application interface to avoid Quit method
problems.
CType(wApp,
Word._Application).Quit(Word.WdSaveOptions.wdDoNotSaveChanges)
wApp = Nothing
End Try
In my application, I open a document, change some values, print, then
exit without saving. This works fine if there are no WINWORD processes
already open. However, if word is already open (with unchanged default
doc) then I get ''Word cannot save this file as it is already open
elsewhere. (Normal.dot)". Is there a setting that I can change to
prevent normal.dot getting changed or alternatively is there any way
of suppressing the message? At the moment the only thing I've managed
to do is make the app sleep for a second so the user has time to close
the prompt before the app crashes - the app then continues fine. But
it's a bit of a rubbish workaround - the user sees the message and has
to take swift action to avoid a crash.
Sorry. I know there are a lot of posts on normal.dot issues, but most
are when closing a document or instance - this is when opening an
instance. I'm not really up on Word automation...
Cheers,
James
Dim wApp As Word.Application
Dim strPath As String
Dim objWord As Word.Document
'Open Word
Try
wApp = New Word.Application ' Message shown when this line
is executed.
Catch ex As Exception
...
End Try
'TODO: This is a workaround for a dialogue box that gets shown
if Word is already open.
'"Word cannot save this file as it is already open elsewhere.
(Normal.dot)"
'This sleep statement gives the user time to close the dialog
box and continue.
'If dialog box is not closed in time then objWord is created
successfully but all properties return {"Call was rejected by callee.
(Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))"}) and the
application will crash when attempting the find and replace.
System.Threading.Thread.Sleep(1000)
Try
'Open separator sheet
objWord = wApp.Documents.Open(strPath, ReadOnly:=True)
Try
'find an replace the fields in the document
objWord.Content.Find.Execute("pclient", False, False,
False, False, False, False, False, True,
CStr(objMember.FilenetClientName), True)
wApp.Visible = False
'print the result
objWord.PrintOut()
MsgBox("Print out has been sent to the default
printer.")
Catch e As Exception
...
Finally
'Close document
objWord.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
objWord = Nothing
End Try
Catch e As Exception
...
Finally
'close word
'CType to _Application interface to avoid Quit method
problems.
CType(wApp,
Word._Application).Quit(Word.WdSaveOptions.wdDoNotSaveChanges)
wApp = Nothing
End Try