Hi,
I hope that you can help me once again....
I have a VBA code which produces a PDF of a worksheet and attaches it to an email (with other details in the email found in the worksheet) when a single condition is met in cell Y32 of the active worksheet.
I want to add some additional VBA to create a PDF of another worksheet ("Support Calculator") and add it to the same email with the first PDF attachment when the two conditions in the active worksheet are met, otherwise, only create the first PDF and revert to the VBA shown below:
Condition 1: Y32 = "OK"
Condition 2: R13 = "3"
The current VBA which works well is shown below:
Sub SEND_FORM()
' Check all Mandatory fields are complete
If (Range("Y32") = "OK") Then
Dim strPath As String,strFName As String
Dim OutApp As Object, OutMailAs Object
'Create PDF of active sheetonly
strPath =Environ$("temp") & "" 'Or any other path, but includetrailing ""
strFName =ActiveWorkbook.Name
strFName =Range("Q9") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName,Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False,OpenAfterPublish:=False
'Set up outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail =OutApp.CreateItem(0)
'Create message
On Error Resume Next
With OutMail
.to =Range("Q13")
.CC =Range("Q14")
.Subject =Range("Q9")
.Body =Range("Q16")
.Attachments.Add strPath & strFName
.Display 'Use only during debugging##############################
'.Send 'Uncomment to send e-mail##############################
End With
'Delete any temp filescreated
Kill strPath & strFName
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox ("Please completeall mandatory fields shown in bold red text before sending for action orauthorisation." & vbNewLine & "" & vbNewLine &"An application cannot include XXX and YYY products in the same form. Please submit seperate application forms for each brand")
End If
End Sub
Many thanks for your valuable assistance
Mark
I hope that you can help me once again....
I have a VBA code which produces a PDF of a worksheet and attaches it to an email (with other details in the email found in the worksheet) when a single condition is met in cell Y32 of the active worksheet.
I want to add some additional VBA to create a PDF of another worksheet ("Support Calculator") and add it to the same email with the first PDF attachment when the two conditions in the active worksheet are met, otherwise, only create the first PDF and revert to the VBA shown below:
Condition 1: Y32 = "OK"
Condition 2: R13 = "3"
The current VBA which works well is shown below:
Sub SEND_FORM()
' Check all Mandatory fields are complete
If (Range("Y32") = "OK") Then
Dim strPath As String,strFName As String
Dim OutApp As Object, OutMailAs Object
'Create PDF of active sheetonly
strPath =Environ$("temp") & "" 'Or any other path, but includetrailing ""
strFName =ActiveWorkbook.Name
strFName =Range("Q9") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName,Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False,OpenAfterPublish:=False
'Set up outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail =OutApp.CreateItem(0)
'Create message
On Error Resume Next
With OutMail
.to =Range("Q13")
.CC =Range("Q14")
.Subject =Range("Q9")
.Body =Range("Q16")
.Attachments.Add strPath & strFName
.Display 'Use only during debugging##############################
'.Send 'Uncomment to send e-mail##############################
End With
'Delete any temp filescreated
Kill strPath & strFName
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox ("Please completeall mandatory fields shown in bold red text before sending for action orauthorisation." & vbNewLine & "" & vbNewLine &"An application cannot include XXX and YYY products in the same form. Please submit seperate application forms for each brand")
End If
End Sub
Many thanks for your valuable assistance
Mark
Last edited: