Hi,
I get an "Input past end of file" error with the code below after the step "readall = myfile.readall":
Any idea how this can be solved? Thanks in advance
I get an "Input past end of file" error with the code below after the step "readall = myfile.readall":
VBA Code:
Sub Paste_Pivot()
Sheets("Missing").Select
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Dim newwb As Workbook
Set newwb = ActiveWorkbook
Dim fso As Scripting.FileSystemObject, readall As Variant
Dim myfile As Scripting.TextStream
Set fso = New FileSystemObject
fso.CreateTextFile ("Desktop")
newwb.PublishObjects.Add(xlSoureRange, "Desktop", "sheet1", newwb.Sheets(1).UsedRange.Address, xlHtmlStatic).Publish (True)
Set myfile = fso.OpenTextFile("Desktop")
readall = myfile.readall
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim omail As Outlook.MailItem
Set omail = o.CreateItem(olMailItem)
omail.HTMLBody = "Hello" & "<Br>" & "<table align=left>" & readall & "</table"
omail.Display
End Sub
Any idea how this can be solved? Thanks in advance