H
Hal Tz
Hi. I want to open a doc in an exisitng Word instance and if there's none to
open it in a new one. Work fine, but when I open in a new one, then
Document.Close (wdPromptToSaveChanges )
doesn't work - it doesn't prompt and does save the changes. The problem is
not there if I open in an existing instance. Any ideas? Thanks.
Private Sub Form_Load()
Dim oWD As Word.Application
Dim oWordDoc As Word.Document
On Error Resume Next
Set oWD = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set oWD = CreateObject("Word.Application")
End If
Set oWordDoc = oWD.Documents.Open("c:\z.doc", , , False)
oWD.Visible = True
oWD.Activate
MsgBox "hit OK"
oWordDoc.Close wdPromptToSaveChanges
Exit Sub
End Sub
open it in a new one. Work fine, but when I open in a new one, then
Document.Close (wdPromptToSaveChanges )
doesn't work - it doesn't prompt and does save the changes. The problem is
not there if I open in an existing instance. Any ideas? Thanks.
Private Sub Form_Load()
Dim oWD As Word.Application
Dim oWordDoc As Word.Document
On Error Resume Next
Set oWD = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set oWD = CreateObject("Word.Application")
End If
Set oWordDoc = oWD.Documents.Open("c:\z.doc", , , False)
oWD.Visible = True
oWD.Activate
MsgBox "hit OK"
oWordDoc.Close wdPromptToSaveChanges
Exit Sub
End Sub