Ok everyone, this is what I'm trying to accomplish,
I am trying to create a macro that will be operated by a button that will format a range, then a selected range is saved as a PDF to any users desktop and THEN attached to an email followed by more formatting inside the excel sheet. I feel like I am close but I am having trouble getting the file to attach properly.
Sub CleanUpPDF()
Application.ScreenUpdating = False
Application.Calculation = xlManual
For Each c In Range("AO1:AO138")
If c.Value = x Then Rows(c.Row).Hidden = True
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
Dim DeskTop As String
DeskTop = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Sheets("Acc. Generation").Range("A1:AN138").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
DeskTop & Application.PathSeparator & "Acc. Memo" & " - " & "0" & Range("AQ5") & Range("C6").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.cc = "dssimagenow.otc.edu"
.Subject = "Acc. Memo"
.Body = "Greetings," & vbLf & vbLf _
& "The report is attached in PDF format." & vbLf & vbLf _
& "Regards,"
.Attachments.Add PDF_File
.Display
End With
' if you want to delete it
'Kill PDF_File
olApp.Quit
Set olApp = Nothing
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
End Sub
When I run this code I am getting a run time error 404: Cannot add the attachment; no data course was provided." from the line
.Attachments.Add PDF_File
Anyone have an ideas?
I am trying to create a macro that will be operated by a button that will format a range, then a selected range is saved as a PDF to any users desktop and THEN attached to an email followed by more formatting inside the excel sheet. I feel like I am close but I am having trouble getting the file to attach properly.
Sub CleanUpPDF()
Application.ScreenUpdating = False
Application.Calculation = xlManual
For Each c In Range("AO1:AO138")
If c.Value = x Then Rows(c.Row).Hidden = True
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
Dim DeskTop As String
DeskTop = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Sheets("Acc. Generation").Range("A1:AN138").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
DeskTop & Application.PathSeparator & "Acc. Memo" & " - " & "0" & Range("AQ5") & Range("C6").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.cc = "dssimagenow.otc.edu"
.Subject = "Acc. Memo"
.Body = "Greetings," & vbLf & vbLf _
& "The report is attached in PDF format." & vbLf & vbLf _
& "Regards,"
.Attachments.Add PDF_File
.Display
End With
' if you want to delete it
'Kill PDF_File
olApp.Quit
Set olApp = Nothing
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
End Sub
When I run this code I am getting a run time error 404: Cannot add the attachment; no data course was provided." from the line
.Attachments.Add PDF_File
Anyone have an ideas?