AnthonyMinnaar
New Member
- Joined
- Aug 25, 2020
- Messages
- 28
- Office Version
- 2013
- Platform
- Windows
Hi folks,
I used the following code to export a sheet to pdf using a cell to set the path and file name. problem is, when the path contains a space, it'll give an error. it works of the path doesn't contain an space.
-----------------------------------------------------------------------------------------------
Sub SaveAsPDF_Click1()
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String
strPathLocation = Worksheets("invulsheet").Range("I2").Value
strFilename = Worksheets("invulsheet").Range("I5").Value
strPathFile = strPathLocation & strFilename
Sheets("1").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPathLocation & strFilename & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub
-----------------------------------------------------------------------------------------------
value in cell I2 = P:/PO 1/ (if I remove the space it works fine, but the directory needs to contain a space)
is there a solution to his?
thanks in advance!
Anthony.
I used the following code to export a sheet to pdf using a cell to set the path and file name. problem is, when the path contains a space, it'll give an error. it works of the path doesn't contain an space.
-----------------------------------------------------------------------------------------------
Sub SaveAsPDF_Click1()
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String
strPathLocation = Worksheets("invulsheet").Range("I2").Value
strFilename = Worksheets("invulsheet").Range("I5").Value
strPathFile = strPathLocation & strFilename
Sheets("1").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPathLocation & strFilename & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
End Sub
-----------------------------------------------------------------------------------------------
value in cell I2 = P:/PO 1/ (if I remove the space it works fine, but the directory needs to contain a space)
is there a solution to his?
thanks in advance!
Anthony.