Late Binding - Word

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>
 
A

Alex Dybenko

Hi,
AFAIR - use other trick metioned in this article:
wdApp2.Quit SaveChanges:=wdDoNotSaveChanges

so you can try to use in instead objWord.NormalTemplate.Saved = True
 
D

Douglas J. Steele

Of course, since Terry's using late binding, that would have to be

wdApp2.Quit SaveChanges:=0

since wdDoNotSaveChanges won't be defined.
 

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

Top