I am developing an Access application and I click on a button which executes the following VBA code to open an existing HTML file in Word.
---------------------------------------------------------
Dim wdApp As Object
Dim doc As Object
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
If Dir$("C:/UDL/Second Notice.htm") <> "" Then
Set doc = wdApp.Documents.Open("C:/UDL/Second Notice.htm")
doc.Activate
doc.Saved = False
End If
-----------------------------------------------------------
The Word Application is launched and the cursor is positioned on the first position of the document.
However, I have to click inside the Word document to get the Word document to have focus.
Then, if I make changes to the document and go directly to close the Word document (without clicking on the SAVE icon), a dialog box comes up with the message:
Do you want to save the changes to "SECOND NOTICE" ?
Yes No Cancel
If I click on Yes and relaunch Word, the changes I made are NOT SAVED.
-----------------------------------------------------------
However, if I make changes to the document and clicking on the SAVE icon and then close the Word document, the changes are SAVED.
Is there a modification I could make to the VBA code listed above to prevent this inconsistency when SAVING the modifications to the html file ?
---------------------------------------------------------
Dim wdApp As Object
Dim doc As Object
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
If Dir$("C:/UDL/Second Notice.htm") <> "" Then
Set doc = wdApp.Documents.Open("C:/UDL/Second Notice.htm")
doc.Activate
doc.Saved = False
End If
-----------------------------------------------------------
The Word Application is launched and the cursor is positioned on the first position of the document.
However, I have to click inside the Word document to get the Word document to have focus.
Then, if I make changes to the document and go directly to close the Word document (without clicking on the SAVE icon), a dialog box comes up with the message:
Do you want to save the changes to "SECOND NOTICE" ?
Yes No Cancel
If I click on Yes and relaunch Word, the changes I made are NOT SAVED.
-----------------------------------------------------------
However, if I make changes to the document and clicking on the SAVE icon and then close the Word document, the changes are SAVED.
Is there a modification I could make to the VBA code listed above to prevent this inconsistency when SAVING the modifications to the html file ?