![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 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 |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Why have it pop up at all, why not replace the msgbox with:
Code:
With ThisWorkbook
.Save
.Close
End With
Cheers, NateO [ This Message was edited by: NateO on 2002-04-25 16:02 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Nate, if i do that, the message will still come up (i use the before close method). I need this message to come up for other reasons (im using a text export on close), it IS needed. So is there a way to answer the msgbox with the shutdown macro?
Thanks |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
Response = MsgBox ("save")
If Response = vbYes Then' User chose Yes. MyString = "Yes" ' Perform some action. Else ' User chose No. MyString = "No" ' Perform some action. End If |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Might want to give post #2 in this thread a look see:
http://www.mrexcel.com/board/viewtop...c=2215&forum=2 Where you see 'your code here, call a macro or insert your code. I don't exactly follow you though, even with the before close method, if you save and close immediately, you shouldn't get the prompt. Maybe under vbno (or vbyes) you go this direction and under the other scenario you do some messages. There's no need to write a macro that clicks a button if you want it to perform the underlying procedure, just need to write the procedure... _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-25 17:06 ] |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Nate, i have the code in the before close as i explained to ask the user if they wnat to save changes. this is neccessary because i an using the before close to export information to a text file. if i dont ask the question, the information will be exported whether the user wants to export it or not.
The code of my shutdown after 12 min macro has this code: Sub ShutDown() ThisWorkbook.Save ThisWorkbook.Close End Sub but on close, it runs the question that i am asking, as it should. so i need the macro to answer yes to the msgbox question to correctly export the text file. I guess i could put the whole export code into the shutdown code, but that would be redundant wouldnt it? any ideas? let me know if i still need to explain more. |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
did you see my post. where respose is = to the msgbox answer?
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Qroozn, yes, but i think im missing something...i have the code very similar to that, but how does "Response" get a vbyes or vbno without the user selecting one? Im trying to accomplish this purely with a macro. The user will not be selecting anything (im trying to make this an auto file save and shutdown after 12 min of inactivity)
did i miss something? thanks |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
OK.
so at the moment with your code it IS NOT exporting to a text file... correct? |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|