Trying to save sheet as PDF on a network

saltire1963

Board Regular
Joined
Aug 11, 2014
Messages
65
I have a workbook that is used by multiple people and I would like for them to be able to save the ActiveSheet as a PDF to their own desktop. Specifically, I do not need what is in the first 8 Rows and therefore the PDF should include only what is in Rows 9 on down.

The line of code I am trying to use is:

Sfile = Application.GetSaveAsFilename _
(InitialFileName:=spath, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File name to save")
If Sfile = "false" Then
MsgBox ("Please Choose A File Name")
Exit Sub
End If

ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Environ("USERPROFILE") & "\Desktop" & "Reports - " & Range("A1"), _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Exit Sub





but this does not work, it gives an error "Run Time Error '1004' Document not saved. The document may be open, or an error may have been encountered when saving." Is it something to do with saving to the USERPROFILE? Can someone show me how to ignore the first 8 Rows when saving to PDF? Thanks in advance
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
HI ,

Sub Exportpd()
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Environ("USERPROFILE") & "\Desktop" & "" & "Reports - " & Range("A1"), _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub

if you dont wan't the file to open once saved change OpenAfterPublish:=True to False
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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