T
Terry
I'm using late binding to open a Word document, but when the document is
closed I get a 'save normal.dot' for the global template.
http://support.microsoft.com/default.aspx?scid=kb;en-us;285885
MS KB suggests using:-
Application.NormalTemplate.Saved = True
where in my code I use
objWord.NormalTemplate.Saved = True
However I still get just one more nag for the normal.dot save before Word
closes properly.
What is the best way to handle the Word document closure?
Dim objWord As Object
Dim strDocPath As String
If Nz(Me.WordDocPath, "") = "" Or _
(Me.WordDocPath = "Double click to enter a Word document location")
Then
GoTo Exit_Event
Else
strDocPath = Me.WordDocPath ' contains path to document from
form control
' Launch Word and load the document
Set objWord = CreateObject("word.application")
booWord = True
objWord.Documents.Open FileName:=strDocPath
objWord.Visible = True
End If
Exit_Event:
var = vbNull
strDocPath = vbEmpty
objWord.NormalTemplate.Saved = True
Exit Sub
Err_Event:
Select Case Err.Number
Case 53 ' File not found
MsgBox "Unexpected error encountered while trying to open your
document." & vbCrLf & _
"Please check you have the correct program installed with which
to view the document file." & vbCrLf & vbCrLf & _
"Error: " & Err.Number & " " & Err.Description, vbOKOnly +
vbCritical, "Unexpected Error Encountered"
objWord.Quit.wdDoNotSaveChanges
booWord = False
'Set docWord = Nothing
Set objWord = Nothing
Resume Exit_Event
<snip>
closed I get a 'save normal.dot' for the global template.
http://support.microsoft.com/default.aspx?scid=kb;en-us;285885
MS KB suggests using:-
Application.NormalTemplate.Saved = True
where in my code I use
objWord.NormalTemplate.Saved = True
However I still get just one more nag for the normal.dot save before Word
closes properly.
What is the best way to handle the Word document closure?
Dim objWord As Object
Dim strDocPath As String
If Nz(Me.WordDocPath, "") = "" Or _
(Me.WordDocPath = "Double click to enter a Word document location")
Then
GoTo Exit_Event
Else
strDocPath = Me.WordDocPath ' contains path to document from
form control
' Launch Word and load the document
Set objWord = CreateObject("word.application")
booWord = True
objWord.Documents.Open FileName:=strDocPath
objWord.Visible = True
End If
Exit_Event:
var = vbNull
strDocPath = vbEmpty
objWord.NormalTemplate.Saved = True
Exit Sub
Err_Event:
Select Case Err.Number
Case 53 ' File not found
MsgBox "Unexpected error encountered while trying to open your
document." & vbCrLf & _
"Please check you have the correct program installed with which
to view the document file." & vbCrLf & vbCrLf & _
"Error: " & Err.Number & " " & Err.Description, vbOKOnly +
vbCritical, "Unexpected Error Encountered"
objWord.Quit.wdDoNotSaveChanges
booWord = False
'Set docWord = Nothing
Set objWord = Nothing
Resume Exit_Event
<snip>