PDA

View Full Version : Convert Word document in HTML via Excel



csaba1960
06-07-2014, 01:15 AM
I have a problem, maybe someone can help me.
From Excel, through VBA I want open a Word document (docx) and convert and save to HTML.
I tried a method but has given a disappointing result. I attach.
I recorded a macro in Word and I pasted in Excel.




Public objWord As Object

Sub deschidWord()
Dim texta(10) As String
Dim ws As Worksheet

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
loca = d.Cells(1, 1) ' my word file name
objWord.Documents.Open loca


objWord.ActiveDocument.SaveAs2 Filename:="D:\proba.htm", FileFormat:= _
wdFormatFilteredHTML, LockComments:=False, Password:="", AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, CompatibilityMode:=0

End Sub

Sub inchidWord()
objWord.ActiveDocument.Close
objWord.Quit
End Sub


A better idea?

westconn1
06-08-2014, 03:55 PM
as there is no way to tell from the sample as to how it is supposed to look, i can only suggest to
parse the document and write your own html