![]() |
|
|
|
#1
|
|||
|
|||
|
I am new to vba and I have googled searched how to convert html document to word using macro without success. I have the html files in a folder and would like the vba to lop through the html files and convert them to word. |
|
#2
|
|||
|
|||
|
Hi!
Try this one Code:
Sub ConvertirHtml_Docx()
Dim objWordApplication As New Word.Application
Dim objWordDocument As Word.Document
Dim strFile As String
Dim strFolder As String
'Change the folder name here
strFolder = "c:\temp\myfolder\"
strFile = Dir(strFolder & "*.html", vbNormal)
While strFile <> ""
With objWordApplication
Set objWordDocument = .Documents.Open(FileName:=strFolder & strFile, _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto, XMLTransform:="")
With objWordDocument
.SaveAs2 FileName:=strFolder & Replace(strFile, "html", "docx"), FileFormat:=wdFormatXMLDocument, CompatibilityMode:=15
.Close
End With
End With
strFile = Dir()
Wend
Set objWordDocument = Nothing
Set objWordApplication = Nothing
End Sub
|
|
| Tags |
| html conversion, macro automatic, word 16 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Symbol characters when saving Word documents as HTML | amos | Word | 3 | 09-30-2023 02:00 PM |
Trying to combine Word documents using Excel macro
|
rotunda | Word VBA | 6 | 06-14-2021 10:42 AM |
Covert PDF to Word .doc?
|
mobileone | Word | 3 | 02-01-2017 10:51 AM |
| covert excel to words | zenholy | Excel | 0 | 07-17-2010 07:55 PM |
| Can you actually write HTML and CSS in a word document and send it as an html page | jackaroo | Word | 0 | 07-12-2010 07:49 AM |