Answer a msgbox yesno with a macro?

robfo0

Active Member
Joined
Feb 19, 2002
Messages
281
Hi everyone,

I have a file that has a shutdown after certain amount of time macro. this works fine, but , on the before_close event, i have this code:

msgbox("Save?",vbyesno)

so this question comes up preventing the shutdown from doing its thing (save, and shutdown).

Is there a way to get the shutdown macro to answer vbyes to this question when it pops up?

Thanks :)
 
Hi Rob
No offense, maybe I'm dense, but I saw your related post yesterday and along with this post I cannot get the big picture of the flow/logic of your code. It sound like a very simple problem to solve...
Maybe attack from another direction?
Tom
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I don't know if this will help you or not:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim Msg As String, Ans As String
If Not Me.Saved Then
Msg = "Do you want to save the changes to"
Msg = Msg & Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion +vbYesNo)

Select Case Ans

Case vbYes
Me.Save

Case vbNo
Me.Saved = True
Exit Sub
End Select
End If
End Sub

James
 
Upvote 0
Qroozn,

I could do what you suggest, but then i the code would still run through the Before_close code, thus creating errors.

TSTom, would you mind taking a look at my workbook? I've been trying quite a few different approaches, then when i solve one thing, another problem arrises :(


I appreciate the help though guys :)
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top