Hi all,
I have an Excelfile that has to save one of his sheets as a PDF file on command with a macro in VBA. It works fine but when i save the file again (this can happen with the exact same documentname) the code overwrites automaticly the old PDF file with the new one. My wish is that the code sees that the PDF allready exists and give an number at the end of the documentname of the second file. So that means that if i save 4 times with the same documentname, the new code results in
Test.pdf
Test(1).pdf
Test(2).pdf
Test(3).pdf
Can someone help me on this one? I will be very, very thankfull..
This is my code:
Private Sub CommandButton3_Click()
Sheets("TEST").ExportAsFixedFormat Type:=xlTypePDF, _
Quality:=xlQualityStandard, _
fileName:="C:\Documents\Testfolder" & Range("AA6")
End Sub
I have an Excelfile that has to save one of his sheets as a PDF file on command with a macro in VBA. It works fine but when i save the file again (this can happen with the exact same documentname) the code overwrites automaticly the old PDF file with the new one. My wish is that the code sees that the PDF allready exists and give an number at the end of the documentname of the second file. So that means that if i save 4 times with the same documentname, the new code results in
Test.pdf
Test(1).pdf
Test(2).pdf
Test(3).pdf
Can someone help me on this one? I will be very, very thankfull..
This is my code:
Private Sub CommandButton3_Click()
Sheets("TEST").ExportAsFixedFormat Type:=xlTypePDF, _
Quality:=xlQualityStandard, _
fileName:="C:\Documents\Testfolder" & Range("AA6")
End Sub