Solved

Using Excel

Posted on 1998-09-30
3
161 Views
Last Modified: 2010-04-30
I am using Excel book as a object in VB program.

This is how I decalred

Dim WithEvents xlApp As Excel.Application
Dim WithEvents xlSheet As Excel.Worksheet
Dim WithEvents xlBook As Excel.Workbook

and I am opening the file through get object

 Set xlBook = GetObject(path)
   
    xlBook.Application.Visible = True
    xlBook.Windows(1).Visible = True
   Set xlSheet = xlBook.ActiveSheet

When the user tries to close the file from excel I have to popup a form which asks whether the user want to save it or not, so I am trapping the before close event

Private Sub xlBook_BeforeClose(Cancel As Boolean)
form to be displayed
End Sub

after this event I have to return to excel, but the problem is then excel is throwing it's dialog box askinh whether the user want to save with YES,NO,CANCEL options. I don't want it to be dispalyed. SO how can I send a Cancel message to excel before coming out of the before close function. No matter what the user opted in my form.
0
Comment
Question by:lesa
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 10 total points
ID: 1437350
Use

Application.ActiveWorkbook.Saved = True

and you won't be promped



Regards
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1437351
Application.ActiveWorkbook.Saved = True

This don't save the workbook.
Just prevent from getting the message
0
 

Author Comment

by:lesa
ID: 1437352
Sorry for the delay
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now