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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create HTML from doc file

Status
Not open for further replies.

MDJ52

MIS
Mar 30, 2001
120
US
I have a large number of DOC files that I need to be able to view via a access form. I am able to use the webbrowser object on an ACCESS form and open htm files. With this I can control the size and the placement on the screen. I would like to be able to control these Word docs the same way, but I have been unable to create an ACCESS form with the linked word format so it can be updated dynamically for source document. My other option was to take a VBA module, open the Word object and save it as a HTML. My code is below. This works fine and I can go through a directory with 200 doc files very comfortable. The only problem is, for every document it creates a new sub folder with the document name and the controls for the particular HTM document. If you delete the control folder, you also get the HTM document. I must allocate space for both the HTM and the control folder. Makes it hard to move it around on the network and point users to it.
So I have 2 problems. Is there a way to dynamically populate an object on an ACCESS form with a Word document? Is there a way to create these HTM documents without the need for the control folders.
Thanks for your assistance.



Function convdatahtml() As Variant

Dim myfile
Dim objwd As Word.Application

Set objwd = CreateObject("word.application")
myfile = Dir("c:\doc\*.doc")

Do While myfile <> &quot;&quot;
objwd.Documents.Open (&quot;c:\doc\&quot; + myfile)
objwd.ActiveDocument.SaveAs filename:=&quot;c:\doc\&quot; + (Left(myfile, Len(myfile) - 4)) + &quot;.html&quot;, fileformat:=wdFormatHTML
objwd.ActiveDocument.Close
myfile = Dir
Loop

objwd.Quit
Set objwd = Nothing

End Function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top