Hi, I am using following code but it is giving me error,
two purpose
1. Make one "folder" (if not already available) on same location of original excel file.
2. Save pdf file on this folder with name as cell range "T3"
MY code
two purpose
1. Make one "folder" (if not already available) on same location of original excel file.
2. Save pdf file on this folder with name as cell range "T3"
MY code
Code:
Sub PDFActiveSheet()
Dim PDFFileName As String
If Dir(ThisWorkbook.Path & "\GGT PDF", vbDirectory) = vbNullString Then MkDir ThisWorkbook.Path & "\GGT PDF"
PDFFileName = GeneratedFileName(ThisWorkbook.Path & "\GGT PDF\ " & Range("T3").Value, 0)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=PDFFileName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Function GeneratedFileName(FileName As String, i As Integer)
Dim testFileName As String
testFileName = FileName
If i <> 0 Then
testFileName = FileName & " (" & i & ")"
End If
GeneratedFileName = testFileName
If Dir(testFileName & ".pdf", vbNormal) > "" Then
GeneratedFileName = GeneratedFileName(FileName, i + 1)
End If
End Function