Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Read-Only and Quitting without saving


Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2003, 07:42 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default Read-Only and Quitting without saving


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.
Reply With Quote
  #2  
Old 04-15-2003, 11:57 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

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.
Reply With Quote
  #3  
Old 04-15-2003, 12:40 PM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Put this before the close code
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)....
Reply With Quote
  #4  
Old 04-15-2003, 01:28 PM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

That works perfectly. Thanks.

BTW, is there any way to turn off the alerts if you close Excel by clicking the X?
Reply With Quote
  #5  
Old 04-15-2003, 03:27 PM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Yes if you would put the same code in the
"Workbook_BeforeClose" event sub

Code:
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.
Reply With Quote
  #6  
Old 04-16-2003, 07:52 AM
burningice96's Avatar
burningice96 burningice96 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: Montreal
Posts: 270
Default

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.
Reply With Quote
  #7  
Old 04-16-2003, 08:40 AM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

Aah sorry,i forgot this whas an VB/Excel app.

Put this in your Form_Unload event :
Code:
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)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->