Hi guys!
Last year the macro was running well - the properties were not changed and this year it is not working anymore.
The code is as follows:
Sub PrintAndSavePdf()
The fat marked turn yellow, when I ran the macro.
I have checked the following:
cells are correctly refered : I1 path and I2 file name
both are within the numbers my OS allows
no unallowed signs
path is ending with \
Just to give examples for I1 and I2:
I1 "\\192.168.50.3\VB\Product Specifications\Ap\Sal\SAI FSA\Conc\"
I2 "2022 SAI-CT-APPLE-JC.03.01"
I really hope someone can help.
Many thanks!
Last year the macro was running well - the properties were not changed and this year it is not working anymore.
The code is as follows:
VBA Code:
Sub PrintAndSavePdf()
Dim strFileName As String
Dim strPath As String
Dim ws As Worksheet
Dim strPathSplit As Variant
Dim myTempPath As String
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Master" Then
strFileName = ws.Range("I2") & ".pdf"
strPath = ws.Range("I1")
myTempPath = ""
If Dir(strPath, vbDirectory) = "" Then
strPathSplit = Split(strPath, "\\")
If UBound(strPathSplit) > 0 Then
myTempPath = "\\"
strPathSplit = Split(strPathSplit(1), "\")
End If
myTempPath = myTempPath & strPathSplit(0) & "\"
For i = 1 To UBound(strPathSplit)
myTempPath = myTempPath & strPathSplit(i) & "\"
If Dir(myTempPath, vbDirectory) = "" Then
MkDir (myTempPath)
End If
Next i
End If
[B] ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strPath & strFileName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False[/B]
End If
Next ws
End Sub
The fat marked turn yellow, when I ran the macro.
I have checked the following:
cells are correctly refered : I1 path and I2 file name
both are within the numbers my OS allows
no unallowed signs
path is ending with \
Just to give examples for I1 and I2:
I1 "\\192.168.50.3\VB\Product Specifications\Ap\Sal\SAI FSA\Conc\"
I2 "2022 SAI-CT-APPLE-JC.03.01"
I really hope someone can help.
Many thanks!