This function takes a range as input and outputs HTML. It copies the range to a new workbook, deletes any drawings, saves the active sheet as an HTML file in the temp folder, reads the file contents, closes the workbook without saving, and returns the HTML.
This function takes a range as input and outputs HTML. It copies the range to a new workbook, deletes any drawings, saves the active sheet as an HTML file in the temp folder, reads the file contents, closes the workbook without saving, and returns the HTML.
This function takes a range as input and outputs HTML. It copies the range to a new workbook, deletes any drawings, saves the active sheet as an HTML file in the temp folder, reads the file contents, closes the workbook without saving, and returns the HTML.
Dim ts As Object Dim TempFile As String Dim TempWB As Workbook TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm" rng.Copy Set TempWB = Workbooks.Add(1) With TempWB.Sheets(1) .Cells(1).PasteSpecial Paste:=8 .Cells(1).PasteSpecial xlPasteValues, , False, False .Cells(1).PasteSpecial xlPasteFormats, , False, False .Cells(1).Select Application.CutCopyMode = False On Error Resume Next .DrawingObjects.Visible = True .DrawingObjects.Delete On Error GoTo 0 End With With TempWB.PublishObjects.Add( _ SourceType:=xlSourceRange, _ Filename:=TempFile, _ Sheet:=TempWB.Sheets(1).Name, _ Source:=TempWB.Sheets(1).UsedRange.Address, _ HtmlType:=xlHtmlStatic) .Publish (True) End With Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2) RangetoHTML = ts.readall ts.Close RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", "align=left x:publishsource=") TempWB.Close savechanges:=False Kill TempFile Set ts = Nothing Set fso = Nothing Set TempWB = Nothing End Function
C:\Users\araujolu\OneDrive - SNEF BRASIL\Documentos\Contas a Receber\PREVISÃO DE