Dear Sir
I am using following code in sheet: Summary
I also one more sheet "Report" which I wanted to save in same pdf
both sheets in same workbook, need to amend this vb code please
I am using following code in sheet: Summary
I also one more sheet "Report" which I wanted to save in same pdf
both sheets in same workbook, need to amend this vb code please
Code:
Sub PDFActiveSheet()
Dim PDFFileName As String
'
PDFFileName = GeneratedFileName(ThisWorkbook.Path & "\TCS # " & Range("O6").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
Last edited by a moderator: