Problem with Opening Workbook

StrangeLuck

New Member
Joined
Mar 25, 2002
Messages
15
Hello,

I have written a macro to automate some monotonous tasks. One of the workbooks opened by the macro is password protected. In the VBA of my macro, I open the workbook using the line
Workbooks.Open FileName:="filename.xls"
and enter the password at the prompt. No problem so far, hmm?

The problem occurs when changes have been made to this workbook by the macro and I want to save it and close it. Excel tells me now that the workbook is opened as "Read-Only" and I cannot save it.

Any suggestions?

Thanks,
StrangeLuck
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

Not sure if this will work as I cannot test it at the moment, but off the top of my head you could try this:

If ActiveWorkbook.ReadOnly Then
ActiveWorkbook.SaveAs fileName:="NEWFILE.XLS"
End If

If you set the filename as the name it already has, then it should write over itself with the new version. Check out 'ReadOnly' in the VBE help.

Nibbs
 
Upvote 0
Alas, the problem is that the macro does not close the password protected workbook, as the user must check over the workbook to make sure that the changes made to it are correct.

Still, when the workbook is opened by:Workbooks.Open FileName:="filename.xls", ReadOnly:=False
the file is still shown as being read-only.

What gives? Any helpers?

Thanks,
StrangeLuck
This message was edited by StrangeLuck on 2002-05-09 11:16
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,981
Members
448,934
Latest member
audette89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top