Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Read-only Workbook

  Asked By: Fabiana    Date: Nov 08    Category: MS Office    Views: 692
  

Is it possible via VBA to save a read-only to same name - that is to
suspend the read-only status?

What I have is a workbook, that users opens read-only. In some situation
VBA adds data to the workbook, and changes should be saved.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Geneva Morris     Answered On: Nov 08

There is no easy answer AFAIK. You cannot Unset ReadOnly status.

I would work along the lines of saving the workbook  under a new name (say
"Newname.xls) and then saving it again under the old name but I think this
will not work directly (it might though!). I suspect Excel hangs onto the file
lock on the old file until the renamed file is closed.

If my suspicion is correct I would try

Create a new module in
Create a macro in personal.xls to do the following
*********
Close Newname.xls
Use the fso to: delete the old file and
rename newname.xls to the old file name
open the file (as R/O if required)
************

You would need to pass the old file name to the macro
as a parameter so save  it to a variable before saving
the file as newname.xls.

If this does not work (because Excel still hangs onto the
file lock on oldfile even after newfile is closed you would
Need to code a vbs script to do the same thing but to
Do it by closing Excel first.

Obviously I have not tried this but I hope it sets you on the
Path to solving your problem.

 
Didn't find what you were looking for? Find more on Read-only Workbook Or get search suggestion and latest updates.




Tagged: