Saving renamed HTML files

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,946
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
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
.
.

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.
 
Upvote 0
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..
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top