Read Only Files - Part 2

J

JT

Below is part of the code I have in a macro. I just add the if statement
below to see if a file is "read only".

If it is "read only" then I want to do the following 3 lines. The first 2
work and when it hits the 3rd line, it jumps out of the module. I can't
figure out what is wrong with the 3rd line because the 3 lines were copied
from the 3 lines from the "If vErrMsg = "Success" Then" if statement and it
works there. The only difference is I haven't checked the ReadOnly property.

Am I missing something? Any help would be greatly appreciated. Thanks...

........
If xlApp.Workbooks(vlBook).ReadOnly = True Then

xlApp.Workbooks(vlBook).SaveAs ("\\Vs300\rental_public\VG\VanRmktg\Rmkt
Processed\X_Read Only Records\" & FoundModel) '(works)

xlApp.Workbooks(vlBook).Close SaveChanges:=False ' (works)

MyObj.deleteFile "\\Vs300\rental_public\VG\VanRmktg\Rmkt to Process\New\" &
FoundModel '(doesn't work)

Else

SendtoUSDatabase

If vErrMsg = "Success" Then

xlApp.Workbooks(vlBook).SaveAs ("\\Vs300\rental_public\VG\VanRmktg\Rmkt
Processed\" & FoundModel) '(works)

xlApp.Workbooks(vlBook).Close SaveChanges:=False '(works)

MyObj.deleteFile "\\Vs300\rental_public\VG\VanRmktg\Rmkt to Process\New\"
& FoundModel '(works)

Else

................................
 
J

joel

I think you may be mising this definition. Myobj should be fs.

Set fs = CreateObject("Scripting.FileSystemObject")
fs.deleteFile "\\Vs300\rental_public\VG\VanRmktg\Rmkt to Process\New\" &
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top