Read-Only and Quitting without saving

burningice96
04-15-2003, 07:42 AM
Alright, two questions about an Excel sheet loaded through VB. How would I load the sheet in Read-Only mode? It's important the users are not able to play with the data on the sheet. Also, is it possible to quit the program without saving? I mean, without giving the option to save. Just when the VB program ends, or when they close the Excel sheet, for it to just quit and not ask if you want to save changes. And then in addition to grey-out the save/open options in the File menu.

Thanks in advance.

burningice96
04-15-2003, 11:57 AM
No one knows anything about this?

The Read-Only and Menu altering isn't all that important. But I really need to know how to quit Excel without the user seeing a Save Changes box. I want to automatically not save and exit the program.

italkid
04-15-2003, 12:40 PM
Put this before the close code

Application.DisplayAlerts = False

This way the save changes dialog wont be displayed.

Maybe protecting your sheet(s) would prevent users to make changes to your sheet(s)....

burningice96
04-15-2003, 01:28 PM
That works perfectly. Thanks.

BTW, is there any way to turn off the alerts if you close Excel by clicking the X?

italkid
04-15-2003, 03:27 PM
Yes if you would put the same code in the
"Workbook_BeforeClose" event sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.DisplayAlerts = False
ActiveWorkbook.Save

End Sub


Even if a user would close the Excel application itself you don't
get the that warning anymore.

burningice96
04-16-2003, 07:52 AM
Just one more question, if you don't mind, italkid.

Where do I put this method? I have the form that launches the spreadsheet, and the module where the spreadsheet is set up.

Thanks.

italkid
04-16-2003, 08:40 AM
Aah sorry,i forgot this whas an VB/Excel app.

Put this in your Form_Unload event :

Private Sub Form_Unload(Cancel As Integer)

XlApp.Workbooks("Yourworkbookname").Close
XlApp.Quit

Set XlApp = Nothing

End Sub

Depending on what happend in the workbook you'll have to add
the .save and/or the displayalerts stuff.
(in this example the Excel App whas dimmed as XlApp)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum