Reputation: 91
The solution provided here by Transistor1 works perfect except for the below issue I am facing.
The output file is including quotes (") at the beginning and ending of the HTML code and its also adding an extra quote if the quote is already present.
For Example, This Code: <div style="background-color:rgba(0,0,0,0.2);padding:60px;">
Becomes Like This: <div style=""background-color:rgba(0,0,0,0.2);padding:60px;"">
I don't want any extra quotes to get added, just want the text as it is.
Please help me resolve this.
Upvotes: 1
Views: 619
Reputation: 33145
It must be the Write method in FileSystemObject that's doing it. VBA has built in file writing ability, so I'm not sure I understand the benefit of using FSO. Here's how I would do it in VBA and it handles quotes as expected.
Public Sub ExportFile()
Dim sFile As String, lFile As Long
Dim rCell As Range
Dim sFldr As String
sFldr = Environ$("userprofile") & "\My Documents\"
For Each rCell In Sheet1.UsedRange.Columns(1).Cells
sFile = sFldr & rCell.Value & ".html"
lFile = FreeFile
Open sFile For Output As lFile
Print #lFile, rCell.Offset(0, 1).Value
Close lFile
Next rCell
End Sub
Upvotes: 1
Reputation: 13
To convert your Excel data to HTML, perform the following steps. These instructions apply to all "ribboned" versions of Excel 2016, 2013, 2010 and 2007:
On the workbook, go to the File tab and click Save As. If you want to export some portion of data only, e.g. a range of cells, pivot table or graph, select it first.
In the Save As dialog, choose one of the following: Web Page (.htm; .html). This will save your workbook or the selection to a web page and create a supporting folder that will store all of the page's supporting files such as images, bullets and background textures.
Single File Web Page (.mht; .mhl). This will save your workbook or the selection to a single file with supporting files embedded into the web page.
Upvotes: 0