Hi All,
With help of previous threads, i've created below code.
I'm attempting to save a active worksheet into pdf in a network folder and email as pdf.
Also I'm not sure how to specify network address to save the file.
But I'm getting below error
With help of previous threads, i've created below code.
I'm attempting to save a active worksheet into pdf in a network folder and email as pdf.
Also I'm not sure how to specify network address to save the file.
But I'm getting below error
VBA Code:
Sub Export_shift()
Dim xSht As Worksheet
Dim xFileDlg As FileDialog
Dim xFolder As String
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim xUsedRng As Range
Set xSht = ActiveSheet
xFolder = ActiveWorkbook.Sheets("Form").Range("l14").Text + ".pdf"
'Save as PDF file
xSht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=xFolder, Quality:=xlQualityStandard
'Create Outlook email
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmailObj = xOutlookObj.CreateItem(0)
With xEmailObj
.Display
.To = "systems@"
.CC = ActiveWorkbook.Sheets("Form").Range("l16")
.Subject = ActiveWorkbook.Sheets("Form").Range("l14")
.Attachments.Add xFolder
If DisplayEmail = False Then
'.Send
End If
End With
End Sub