I've got a form that creates a back up for printing (Because printing causes issues and the sheet becomes unusable) so to stop people using the printed sheet rather than the back up it created, I'd like to either delete the print sheet after printing, or to delete it when the back up is reopened.
Currently I'm trying to do it as when you open the workbook, it will delete the print copy. Issue is that when you first open the sheet, there won't be a print copy so it says cannot find file, is there a way of doing a
If file exists then
delete
else
Nothing
End If
After googling the issue I've been trying with:
That comes up with an error "Object not found" and I'm not sure why, I'm not really familiar with this Dir function so can't tell if it's the right one to use in seeing it it exists.
I'd be happy if there was a function for "Do this, if it's an error than just end" but I have no idea on the code for that.
Any help on this is greatly appreciated
Best regards
~Will S
Currently I'm trying to do it as when you open the workbook, it will delete the print copy. Issue is that when you first open the sheet, there won't be a print copy so it says cannot find file, is there a way of doing a
If file exists then
delete
else
Nothing
End If
After googling the issue I've been trying with:
Code:
Private Sub Worksheet_Activate()
Call KillFile
End Sub
Sub KillFile()
If Dir(ThisWorbook.Path & "\TransfersheetPrintCopy.xlsm") <> "" Then
Kill (ThisWorkbook.Path & "\TransfersheetPrintCopy.xlsm")
Else
End If
End Sub
That comes up with an error "Object not found" and I'm not sure why, I'm not really familiar with this Dir function so can't tell if it's the right one to use in seeing it it exists.
I'd be happy if there was a function for "Do this, if it's an error than just end" but I have no idea on the code for that.
Any help on this is greatly appreciated
Best regards
~Will S