Save as pdf in a network folder and email as pdf

de076348

New Member
Joined
Jun 27, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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

1624847217215.png


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
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assuming that your error is ocurring on the ExportAsFixedFormatLine. To do any type of saveas or export, you need to specify the full path of the file, including the drive letter, folder path, filename, and extension. G: is a network drive for me, so something like G:\EMS\Training\Task List.xlsx will work. It's obviosuly easier if your drive is mapped to a letter but it's also possible to do if that's not the case.

Also make sure that xFolder evaluates to a valid file path with the correct folder delineations ("\") and no invalid characters.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top