Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

How to convert word to html with .net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doug Batchelor - 08 Jan 2008 01:14 GMT
I store word docs in a sql2005 database as images. I can retrieve the docs
from the database as byte arrays. I need to be able to then save the docs as
temporary files on the server in html format. I think I sould be able to use
microsoft.office.interop.word to accomplish this but I have no idea how to
start. I am using asp.net 2.0 and vb.net. If anyone has any vb ( or c# code
that I could use, I would really appreciate it)
Shauna Kelly - 08 Jan 2008 11:15 GMT
Hi Doug

In VBA you would need something like the following. You'll need to
translate the syntax to the language your choice.

Sub SaveActiveDocAsHTML

Dim oDoc as Word.Document
Dim appWord as Word.Application
Dim sSavePFN as string

   set appWord = Word.Application 'you'll have to get a reference to
the Word app some how

   on error resume next
   'You can't ever be certain that there is an active document
   set oDoc = appWord.ActiveDocument
   on error goto 0 'you need better error handling in the real world

   'Get the path and file name to which you want to save the document
   sSavePFN = "c:\whatever\somewhere.htm"

   oDoc.SaveAs FileName:=sSavePFN , _
       FileFormat:=wdFormatHTML, _
       AddToRecentFiles:=True

End Sub

This will save the document as an HTML file at the location specified.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I store word docs in a sql2005 database as images. I can retrieve the
>docs
[quoted text clipped - 7 lines]
> code
> that I could use, I would really appreciate it)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.