Saving renamed HTML files

daverunt

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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

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,908
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..
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,592
Messages
5,838,253
Members
430,536
Latest member
Manoj Gaidhankar

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
Top