victorel21
New Member
- Joined
- Jul 8, 2021
- Messages
- 25
- Office Version
- 365
- Platform
- Windows
HI everyone Im trying to create a pdf and send but im encountering an error i havent seen before.
Could any one help? Below the code.
Sub Accounts()
Dim MonOutlook As Object
Dim oBjmail As Object
Dim olFormatHTML As Object
Dim strNomClasseur As String
Dim strmsg3 As String
Dim myFile3 As Variant
Dim ws3 As Worksheet
Dim strfile5 As String
Dim strfile4 As String
'On Error GoTo errHandler
Sheets("PurchaseOrder").Activate
PO = Range("F3")
Sheets("Accounts").Activate
Set ws3 = ActiveSheet
strfile4 = "Account_amounts" & PO & ".pdf"
strfile5 = ThisWorkbook.Path & "\" & strfile2
Debug.Print strfile5
myFile3 = Application.GetSaveAsFilename _
(InitialFileName:=strfile4, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile3 <> "False" Then
ws3.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile3, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set MonOutlook = CreateObject("Outlook.Application")
Set oBjmail = MonOutlook.CreateItem(0)
Set olFormatHTML = MonOutlook.CreateItem(1)
strNomClasseur = strNomFichier
With oBjmail
.display
End With
Signature = oBjmail.HTMLbody
strmsg3 = "<BODY>Greetings,<br /><br> Please see the attached amounts for accounts.<br /><br>Regards.</BODY>"
titre3 = "Accounts_amounts" & PO
With oBjmail
.Attachments.Add strfile5
.Subject = titre3
.HTMLbody = strmsg3 & vbNewLine & Signature
.BodyFormat = 2
.display
End With
Set MonOutlook = Nothing
Set oBjmail = Nothing
Sheets("PurchaseOrder").Activate
'Else
'exitHandler:
'Exit Sub
'errHandler:
'MsgBox "Could not create PDF file"
'Resume exitHandler
'Sheets("PurchaseOrder").Activate
End If
End Sub
Could any one help? Below the code.
Sub Accounts()
Dim MonOutlook As Object
Dim oBjmail As Object
Dim olFormatHTML As Object
Dim strNomClasseur As String
Dim strmsg3 As String
Dim myFile3 As Variant
Dim ws3 As Worksheet
Dim strfile5 As String
Dim strfile4 As String
'On Error GoTo errHandler
Sheets("PurchaseOrder").Activate
PO = Range("F3")
Sheets("Accounts").Activate
Set ws3 = ActiveSheet
strfile4 = "Account_amounts" & PO & ".pdf"
strfile5 = ThisWorkbook.Path & "\" & strfile2
Debug.Print strfile5
myFile3 = Application.GetSaveAsFilename _
(InitialFileName:=strfile4, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile3 <> "False" Then
ws3.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile3, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set MonOutlook = CreateObject("Outlook.Application")
Set oBjmail = MonOutlook.CreateItem(0)
Set olFormatHTML = MonOutlook.CreateItem(1)
strNomClasseur = strNomFichier
With oBjmail
.display
End With
Signature = oBjmail.HTMLbody
strmsg3 = "<BODY>Greetings,<br /><br> Please see the attached amounts for accounts.<br /><br>Regards.</BODY>"
titre3 = "Accounts_amounts" & PO
With oBjmail
.Attachments.Add strfile5
.Subject = titre3
.HTMLbody = strmsg3 & vbNewLine & Signature
.BodyFormat = 2
.display
End With
Set MonOutlook = Nothing
Set oBjmail = Nothing
Sheets("PurchaseOrder").Activate
'Else
'exitHandler:
'Exit Sub
'errHandler:
'MsgBox "Could not create PDF file"
'Resume exitHandler
'Sheets("PurchaseOrder").Activate
End If
End Sub