ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read Only Issue (https://www.excelbanter.com/excel-programming/375884-read-only-issue.html)

PJ Usher

Read Only Issue
 
Excel 2000

I'm trying to write a macro that will automatically update WorkbookB from
WorkbookA. I have it worked out - almost. The problem is that WorkbookB
has to have the Read-only checked in it's document property making saving
the document a little tricky.

In the macro I have
Workbooks.Open Filename:="WorkbookB.xls", Readonly=False
Thinking that it will open WorkbookB in ReadWrite Mode but it still open as
ReadnOnly.

Is there a way to change a workbook from read only, make document changes
then save document back with read-only, without changing document name?

Thank you

PJ



Ken Puls

Read Only Issue
 
Hi there.

This is written in the reply, and therefore not tested, but hopefully
should work for you.

Dim wb as Workbook
Set wb = Workbooks.Open Filename:="WorkbookB.xls"

'Remove Read only status
SetAttr wb.FullName, vbNormal

'Do stuff here

'Make workbook read only
SetAttr wb.FullName, vbReadOnly

Set wb = Nothing

HTH,

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca





PJ Usher wrote:
Excel 2000

I'm trying to write a macro that will automatically update WorkbookB from
WorkbookA. I have it worked out - almost. The problem is that WorkbookB
has to have the Read-only checked in it's document property making saving
the document a little tricky.

In the macro I have
Workbooks.Open Filename:="WorkbookB.xls", Readonly=False
Thinking that it will open WorkbookB in ReadWrite Mode but it still open as
ReadnOnly.

Is there a way to change a workbook from read only, make document changes
then save document back with read-only, without changing document name?

Thank you

PJ



PJ Usher

Read Only Issue
 

Hi Ken

I was able to use SetAttr to change the read only property. Thank you very
much for you help.

PJ


"Ken Puls" wrote in message
...
Hi there.

This is written in the reply, and therefore not tested, but hopefully
should work for you.

Dim wb as Workbook
Set wb = Workbooks.Open Filename:="WorkbookB.xls"

'Remove Read only status
SetAttr wb.FullName, vbNormal

'Do stuff here

'Make workbook read only
SetAttr wb.FullName, vbReadOnly

Set wb = Nothing

HTH,

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca





PJ Usher wrote:
Excel 2000

I'm trying to write a macro that will automatically update WorkbookB

from
WorkbookA. I have it worked out - almost. The problem is that

WorkbookB
has to have the Read-only checked in it's document property making

saving
the document a little tricky.

In the macro I have
Workbooks.Open Filename:="WorkbookB.xls", Readonly=False
Thinking that it will open WorkbookB in ReadWrite Mode but it still open

as
ReadnOnly.

Is there a way to change a workbook from read only, make document

changes
then save document back with read-only, without changing document name?

Thank you

PJ






All times are GMT +1. The time now is 02:48 PM.

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