Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-05-2019, 11:53 AM
LBruce LBruce is offline Save As new file type Windows 10 Save As new file type Office 2013
Novice
Save As new file type
 
Join Date: Aug 2019
Posts: 9
LBruce is on a distinguished road
Default

Thanks, but it looks like I may not have been perfectly clear.

I need a macro to open every HTM or HTML file in a specific folder and convert them all, saved in the same folder with the original file name. I have part of the VBA enough to open and close the files throughout the directory (copied from a macro from another process of mine), but am missing the steps to save a copy as a Word doc.

The "Call to SaveAsDocx" part is what I can't figure out.

Code:
Sub ConvertHTMLtoDOC()
Dim file
Dim path As String

' Path to your folder. Make SURE you include the terminating "\"
'YOU MUST EDIT THIS.
path = "\\MYPATH"

'Change this file extension to the file you are opening. .htm is listed below.
'YOU MAY NEED TO EDIT THIS.
file = Dir(path & "*.htm*")
Do While file <> ""
Documents.Open FileName:=path & file

' This is the call to the macro you want to run on each file the folder
Call SaveAsDocx

ActiveDocument.Close

' set file to next in Dir
file = Dir()
Loop
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save As new file type save dialog box promt doesn't save file brmveen Word VBA 2 11-04-2015 12:51 AM
Save As new file type Word 2007 , when I save a .doc or .docx file the file type is showing "Empty" Tomc29 Word 9 06-10-2015 03:04 AM
Set File Type when clicking Save As Madbags Word VBA 1 10-10-2014 01:07 PM
Save As new file type Word file type in 2007 casaserves Word 4 08-03-2013 01:11 AM
Getting COMException Incompatible file type and file extension sbalerao Mail Merge 0 04-21-2011 10:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft