ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel follow question for [email protected] (https://www.excelbanter.com/excel-discussion-misc-queries/87819-excel-follow-question-ardus-petus%40laposte-net.html)

Bernadette

Excel follow question for [email protected]
 
Ardus, Yesterday you answered the below question for me, but I need further
clarification. Can I insert a pop up window in Excel to ask a ? b/4 closing?
I would like to create a pop up box simular to the one that appears when you
are closing your document and are asked to save. Is there a function to
allow this.

What method or event will trigger this code to execute?





Kevin B

Excel follow question for [email protected]
 
You can declare an integer variable and in the OnClose event you can use the
message box function to ask your user for a response:

dim intOnClose as Integer

intOnClose = msgbox("Insert Question Here",vbYesNo,"Title Text for the
Dialog box")

if intOnClose = vbYes then
do something here
else
do something here
end if



--
Kevin Backmann


"Bernadette" wrote:

Ardus, Yesterday you answered the below question for me, but I need further
clarification. Can I insert a pop up window in Excel to ask a ? b/4 closing?
I would like to create a pop up box simular to the one that appears when you
are closing your document and are asked to save. Is there a function to
allow this.

What method or event will trigger this code to execute?





Bob Phillips

Excel follow question for [email protected]
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Closing " & ThisWorkbook.Name & " now"
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Bernadette" wrote in message
...
Ardus, Yesterday you answered the below question for me, but I need

further
clarification. Can I insert a pop up window in Excel to ask a ? b/4

closing?
I would like to create a pop up box simular to the one that appears when

you
are closing your document and are asked to save. Is there a function to
allow this.

What method or event will trigger this code to execute?








All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com