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 edit an HTML type file in Word from an Access Application

Status
Not open for further replies.

kpmvb

Programmer
Jan 4, 2006
5
US
Let's say I use the following VBA code:
-----------------------------------------------------------
Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
If Dir$("C:/UDL/Second Notice.htm") <> "" Then
wdApp.Documents.Open "C:/UDL/Second Notice.htm"
End If
-----------------------------------------------------------
A couple of issues arise when I use this code as follows:

First of all, let's assume I need to save the file as an HTML type file.

When the user clicks on a button of my interface screen, this action causes the execution of the lines of VBA code listed above. The Word Application opens up and the cursor is placed in front of the first character of the existing text in the document opened which is fine.

However, the Title bar at the top of the Word Document is grayed out and the document cannot be updated. If I then proceeed to click on the Title Bar, then the document gets focus and the existing text can be upated.

Now if the user makes changes to the document and hits the X Close button in the top righthand corner without saving the document by clicking on the SAVE icon,
a Microsoft Office Word dialog box comes up and displays the message "Do you want to save the changes to "Second Notice" ?

YES NO CANCEL

If I click on YES, the document will then close.

If I reenter this document by clicking on the Interface button once again to open the Word Document, the changes were never actually saved.

However, if I make changes to the document and then click on the SAVE icon, the changes will actually be saved once I close down the document via the CLOSE button
in the top right corner of the Word Application.

Do you know how I can fix this VBA code to cause the Word document to get focus so that the user will be in EDIT mode as soon as the Word Document opens
with the cursor in the first position ?

Also why can't the document actually be saved without using the SAVE icon when I close down the Application and the dialog box asks if I want to save the file ?
 
Have a look at the AppActivate instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top