BeforeSave event problem
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: BeforeSave event problem

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    India
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi,

    I am in some problem with the "BeforeSave" even of the Workbook. Suppose, I have written a code under the said event. Now, the user chooses the "File->Save As" (or "File->Save" when he is first time saving) option. As soon as he does it the "BeforeSave" event is called up in which I have written some code for saving something (it may be any external files or any registry settings etc.) that SHOULD ONLY BE CALLED IF THE WORKBOOK IS SAVED PROPERLY. But say, the user changes his/her mind and clicks the "Cancel" button of the "File SaveAs" dialog button. But, then what will happen to my event? In that case I will not be revert back my work done in the "BeforeSave" event. So what to do? I want to do something ONLY IF THE WORKBOOK IS SAVED. Please help me.

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi
    Test for a cancel in the following way:
    Here is an Example:

    fileSaveName = Application.GetSaveAsFilename(PathToSave, _
    fileFilter:="Excel Workbook (*.xls), *.xls")
    If fileSaveName <> False Then
    ActiveWorkbook.SaveAs fileSaveName
    Else
    'if false, user cancelled
    'Code to deal with cancel
    End If

    Hope this helps you!
    Tom

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com