After_Save Event???

Hi to all.

I have a problem.

For some sheets, I set to invisible before save.

Now, I need set to visible the sheets after save, but there aren`t a After_Save Event...

How can I solve my problem Any idea

Thanks & Regards.




Answer this question

After_Save Event???

  • Matt B

    The code in blue below may help. MacroSave is my global variable

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim sa As Boolean

    sa = SaveAsUI
    If Not MacroSave Then
    Cancel = True
    MySave (sa)
    End If
    End Sub

    Private Sub Workbook_Open()
    MacroSave = False

    End Sub

    Public Sub MySave(SaveAsUI)
    Dim fn, pn As String
    Dim resp As Variant

    MacroSave = True
    If SaveAsUI = True Then
    Do
    fn = Application.GetSaveAsFilename
    Loop Until fn <> False
    ActiveWorkbook.SaveAs Filename:=fName
    fn = ActiveWorkbook.Name
    pn = ActiveWorkbook.Path
    resp = MsgBox("File - " & pn & "/" & fn, vbOKOnly)
    Else
    ActiveWorkbook.Save
    resp = MsgBox("File - Saved")
    End If
    MacroSave = False
    End Sub


  • Cwoja

    thanks * 100000...!!!

    you have save my life!!! hehe

    really thank you very much friend.

    Regards.



  • Henri De Veene

    yeah, I implement it and runs great for save excel file.

    Now, the problem is when the user want to Save As...how can i show the Save Dialog If not, I will try to do a form that ask for the file name/path, and then use it into workbook.SaveAs method, right

    thanks again.



  • Antonio Ooi

    I think you can test the value of SaveAsUi to see if the SaveAs dialog will be displayed for the user.

    Regards

    ADG


  • Rayco J.

    I would try to use the BeforeSave event to cancel the users request to save, and do your own saving routine. I suspect you may need to set a global variable so that you can determine if the save request is from our code or the user.
  • &amp;#12506;&amp;#12524;&amp;#12452;&amp;#12521;

    If you handle both save and save as in your routine, you can capture the details just after the as save.
  • rsdu

    please, I need some help. I cant find any solution for this :(

    any idea

    Thanks & Regards



  • aek

    I dont understand how can I capture the details of SaveAs after do user save, because the save never do...

    I put the code. saveSwitch is a global variable defined into a module.

    ---------------------------------------------------------------------------------------

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If saveSwitch <> 1 Then
    Cancel = True
    'HIDE SHEETS
    Call visibilitySheet(1)
    If SaveAsUI = True Then
    Call saveReport(1)
    Else
    Call saveReport(0)
    End If
    End If
    End Sub

    Public Sub saveReport(iSaveMode As Integer)
    Dim sPath As String
    saveSwitch = 1

    'if SaveAS mode, ask for file path
    If iSaveMode = 1 Then
    sPath = InputBox("Input the file name and path.", "WUR - Save As", Excel.ThisWorkbook.Path & "\" & Excel.ThisWorkbook.Name)
    ThisWorkbook.SaveAs sPath
    Else
    ThisWorkbook.Save
    End If

    'show the sheets again
    Call visibilitySheet(0)
    saveSwitch = 0
    End Sub
    ------------------------------------------------------------------------------------

    Thanks for all your help.



  • Dave S. Anderson

    This tells you if the dialog will be presented. You probably need to incoporate this into your save routine so that the code either calls save or save as. You can get the name and path from the active sheet after the save.
  • Gerardo Cignarella

    But if I cancel the save into Before Save, the SaveAs Dialog never be shown...then I cant get the path that the user wants, right

  • Rekoob1

    With SaveAsUi value...Can I determine if the SaveAs dialog is shown Can I get the file path

    Sorry, but this is my first project with VBA

    Thanks



  • Wout

    thank you very very much!!

    now, I try do it. I hope that works.

    thanks ;-)



  • After_Save Event???