Editing a Read Only Excel File via VBE

B

bg_ie

Hi,

I have an excel file which runs some vbe via the DocumentOpened event
handler. This code involves the proessing of data, the results of which
are plotted within the excel doc. Finally, the event handler saves the
doc so that when you close it, you are not propted to save the file.
The problem is, I dont what the file to be editable after the event
handler has run. In otherwords, I want to set it to read-only after I
exit the handler.

How might I do this?

Thanks,

Barry.
 
C

Chip Pearson

Try something like the following in the ThisWorkbook code module:

Private Sub Workbook_Open()
'''''''''''''''''''''''
' your code here
''''''''''''''''''''''
Application.DisplayAlerts = False
ThisWorkbook.ChangeFileAccess xlReadOnly
Application.DisplayAlerts = True

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

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