Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Lambtwo
 
Posts: n/a
Default Warning message on file close

My program has a macro that should normally be executed before the user
closes the file. The macro transfers data to a destination file, but there
are times where the user forgets or neglects to run it.

I would like to have a warning message display only when the user attempts
to close the file and the macro has not been run. I don't want to go as far
as forcing the macro as there are times when the file is opened and worked
on and then may be aborted for a legit reason.

Any suggestions?



  #2   Report Post  
Vasant Nanavati
 
Posts: n/a
Default Warning message on file close

You would need an event macro to be placed in the ThisWorkbook code module:

Something like (untested):

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Do you want to run the XXX macro?", _
vbYesNo + vbQuestion, "Reminder!") = vbYes Then
Cancel = True
XXX
End If
End Sub

where "XXX" is the name of the macro.

This is plain vanilla; you could add error-handling, testing whether the
macro has already been run, etc.

--

Vasant




"Lambtwo" wrote in message
news:O1f7f.297503$tl2.119111@pd7tw3no...
My program has a macro that should normally be executed before the user
closes the file. The macro transfers data to a destination file, but there
are times where the user forgets or neglects to run it.

I would like to have a warning message display only when the user attempts
to close the file and the macro has not been run. I don't want to go as
far as forcing the macro as there are times when the file is opened and
worked on and then may be aborted for a legit reason.

Any suggestions?





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding an error message at close of file when criteria are met Dave Excel Discussion (Misc queries) 3 August 12th 05 07:56 PM
What is the VBA code to delete a sheet without warning message? [email protected] Excel Discussion (Misc queries) 2 August 9th 05 04:16 PM
Getting message can't save all data in excel xls file Melody05 Excel Discussion (Misc queries) 2 June 29th 05 12:20 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Error Message appearing when saving a file JaneC Excel Discussion (Misc queries) 0 November 25th 04 10:35 PM


All times are GMT +1. The time now is 04:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"