Saving renamed HTML files

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,847
Office Version
  1. 2013
Platform
  1. Windows
Hi,

Can anyone point me in the right direction?
I am using Excel to open an HTML file and then renaming it using Save As.
It does this but it saves in Excel format html and includes a folder of the same name with the stylesheet and a load of other unwanted bilge, which must be present to open the file in future.

Is there a way to copy and rename the HTML file without changing its format to Excel. I don't need to open it.


Code:
Nme = "TestHTMLAcc"
TimeStamp = " - 10-07-09 121827"

' Open the HTML file 

    Workbooks.Open Path & "UserAccount123456 - 10-07-09 121827.html"
  
'Save as with new name  
       ActiveWorkbook.SaveAs filename:=Nme & TimeStamp & ".html"
       ActiveWorkbook.Close True
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

ParamRay

Well-known Member
Joined
Aug 6, 2014
Messages
1,195
.
.

Two options:

Code:
ActiveWorkbook.SaveAs _
    Filename:="C:\Users\jsmith\Desktop\Book1.htm", _
    FileFormat:=xlHtml

Or:

Code:
ActiveWorkbook.SaveAs _
    Filename:="C:\Users\jsmith\Desktop\Book1.mht", _
    FileFormat:=xlWebArchive

Try them both. See which is best for you.
 

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,847
Office Version
  1. 2013
Platform
  1. Windows
Hi,

thanks for the reply but the .mht is no good to me and the xHTML is the default that causes my issue.
Not to worry I have been able to copy the file using FileCopy with the FileScriptingObject instead.

I have an issue with that now not using string variables in the writeLine for another file - but that's going in another post.

Cheers..
 

Watch MrExcel Video

Forum statistics

Threads
1,109,549
Messages
5,529,465
Members
409,883
Latest member
asharris90
Top