Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Editing a Read Only Excel File via VBE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bg_ie@yahoo.com - 13 Dec 2006 17:27 GMT
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.
Chip Pearson - 13 Dec 2006 18:35 GMT
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

Signature

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

> Hi,
>
[quoted text clipped - 11 lines]
>
> Barry.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.