ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read Only Files - Part 2 (https://www.excelbanter.com/excel-programming/428234-read-only-files-part-2-a.html)

JT

Read Only Files - Part 2
 
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

................................

--
JT

joel

Read Only Files - Part 2
 
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\" &

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

...............................

--
JT



All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com