Link to home
Start Free TrialLog in
Avatar of Shawn
ShawnFlag for Canada

asked on

do not delete if error

The code below copies a file and renames it in a new folder. Right now the old file is deleted right away but I only want to delete it if the copy suceeded.

 
Private Sub btnAttributeAll_Click()

Dim SourceFile, DestinationFile
SourceFile = "G:\Scans\Scan - 262i\test.jpg"    ' Define source file name.
DestinationFile = "G:\Scans\test moved\testmoved.jpg"    ' Define target file name.
FileCopy SourceFile, DestinationFile    ' Copy source to target.

Kill SourceFile
MsgBox "moved file " & SourceFile

End Sub

Open in new window


How would I do this?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shawn

ASKER

thank you