Suppressing Input Box

O

Orion Cochrane

I have an application that prompts me to enter data on startup into an input
box and after saving. I also have a Workbook_BeforeClose event that saves the
file when closing, but it calls the BeforeSave event I have. Is there a way
to save without calling the BeforeSave event?
 
O

Orion Cochrane

I forgot to mention the procedure that incorporates the input box (in
ThisWorkbook):

Private Sub Deposit()
Application.StatusBar = something
Range("A1").Value = InputBox(Prompt, Title)
Call Messages.Messages
End Sub

As a reference, here are the occurrences of this procedure:

Private Sub Workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)
'Performs actions of Workbook_BeforeClose but does not close the workbook
when complete
Call Workbook_BeforeClose(True)
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Resets workbook and saves file
Sheets(1).Select
Range("All").ClearContents
Range("A3").Select
If Cancel = False Then
ThisWorkbook.Save
Application.StatusBar = False
End If
If Cancel = True Then Call Deposit
End Sub
 
C

Chip Pearson

You can use the EnableEvents property to prevent Excel from calling
event procedures. E.g,

Application.EnableEvents = False
' save the file. won't call BeforeSave
Application.EnableEvents = True

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
O

Orion Cochrane

Perfect! This will help me with other applications I use. Thanks, Mr. MVP
(Most Valuable Programmer) :)
 

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