I built macros to automate a sales reporting process. I am leaving the company and trying to ensure the sales report will be usable after I leave. My boss who will be running the report uses a MacBook Air.
When I run the macro, the first error that comes up says "Print - Error while printing". Once I clear that error, then I get another error "Run-time error '1004': Application-defined or object defined error.
See below for my code. Anyone know what I need to change to get this to work on a Mac? The debugger specifies the ActiveSheet.Export selection on the 4th line/section as the isssue.
__________________________________________________________________________________
When I run the macro, the first error that comes up says "Print - Error while printing". Once I clear that error, then I get another error "Run-time error '1004': Application-defined or object defined error.
See below for my code. Anyone know what I need to change to get this to work on a Mac? The debugger specifies the ActiveSheet.Export selection on the 4th line/section as the isssue.
__________________________________________________________________________________
Rich (BB code):
Sub ReportSavePDFsendEmail()
Const myPath = "C:\Users\SP3\Dropbox (1 Stone Solutions)\1 Stone Solutions Team Folder\Houston\Jacob Robinson\Sales Report\Past Reports"
.Sheets(4).Name, ThisWorkbook.Sheets(5).Name, ThisWorkbook.Sheets(6).Name)).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=myPath & Sheets(2).Range("B2") & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' selectReport
Sheets("Report").Select
Range("A1").Select
' send as PDF attachment
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Display
.To = "name@email.com; name@email.com"
.CC = ""
.BCC = ""
.Subject = Range("B9")
.Attachments.Add (myPath & Sheets(2).Range("B2") & ".pdf")
.HTMLBody = "****** style=font-size:11pt;font-family:Calibri>Team,<br>" & _
"<br>See attached for this week's sales report.<br>" & _
"<br>Let me know if you have any questions or comments.<br>" & _
"<br>Thanks,<br>" & _
.HTMLBody
'.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Last edited by a moderator: