LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Trap on close event and control save

Using Office 2003 and Windows XP;

I am trying to trap the Workbook_BeforeClose event so that I can substitute
a call to my own save function, see below:

Public Function FileSavePrompt(argPath As String, argName As String) As Long
'SUPPLY A DEFAULT FILE NAME AND PROMPT THE USER TO SAVE THE FILE;
Application.ScreenUpdating = True
Dim lResponse As Long
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
.ButtonName = "SAVE!"
.InitialView = msoFileDialogViewDetails
.InitialFileName = argPath & argName
.Title = "SAVE FILE AS EXCEL"
End With
lResponse = Application.FileDialog(msoFileDialogSaveAs).Show
'Save the file if user did not click 'Cancel'
If lResponse = -1 Then Application.FileDialog(msoFileDialogSaveAs).Execut e
End Function

This function allows me to capture and enter a custom suggested file name
for the user. However, I cannot get this to function correctly. In many
cases, it errors so badly, I get the: "Do you want to send this error to
Microsoft" message.

Can someone tell me how to invoke this correctly? I've tried all
combinations of Cancel = True and Application.EnableEvents = False, but I
must not be putting my code in the right place or something. Any help
appreciated.

Thanks much in advance.
 
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
Trap the Send-To event Otto Moehrbach Excel Programming 2 March 18th 07 12:53 AM
How to trap the worksheet_BeforeDeactivate event? OKLover[_2_] Excel Programming 1 July 12th 05 10:34 AM
How to trap delete row event and hide column event? Alan Excel Programming 3 April 26th 05 04:25 PM
Don't save before close event? Don Wiss Excel Programming 1 September 18th 04 01:51 AM


All times are GMT +1. The time now is 01:59 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"