Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use VBA code to automatically modify an HTML type file in a Wor

Status
Not open for further replies.

kpmvb

Programmer
Jan 4, 2006
5
US
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 ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top