Here is the code i use to print a document using Word
Basically i open a ".dot" document, fill the bookmark, print the document then quit without
saving it
It works fine with office 2002
But when the programs runs with office 2003, i have some problems
If outlook 2003 is currently running on the machine, closing the word document doesnt work and hangs
with the following message
"Word cannot save this file because it is already open elsewhere
(Cocuments and Settings\...\Normal.dot)"
And the user has to click on button OK to close the word window
If Outlook 2003 is not running on the machine (just installed), everythings works fine
Any solution to this problem (except asking user to close Outlook before printing) ?
(PS : users have the option "use Word as email editor" selected
Basically i open a ".dot" document, fill the bookmark, print the document then quit without
saving it
Dim oword As Object
Dim odoc As Object
Dim file As String
File="c:\test.dot"
oword = CreateObject("Word.Application")
oword.visible = False
Try
odoc = oword.documents.open(file)
Catch ex As Exception
MsgBox("Cannot find the template " & file & ". Operation cancelled")
oword.quit(0)
Exit Sub
End Try
odoc.bookmarks("Title").RANGE.TEXT = Title
odoc.bookmarks("SubTitle").RANGE.TEXT = SubTitle
odoc.printout(0)
odoc.APPLICATION.QUIT(0)
It works fine with office 2002
But when the programs runs with office 2003, i have some problems
If outlook 2003 is currently running on the machine, closing the word document doesnt work and hangs
with the following message
"Word cannot save this file because it is already open elsewhere
(Cocuments and Settings\...\Normal.dot)"
And the user has to click on button OK to close the word window
If Outlook 2003 is not running on the machine (just installed), everythings works fine
Any solution to this problem (except asking user to close Outlook before printing) ?
(PS : users have the option "use Word as email editor" selected