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.
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.
After_Save Event???
adi1980
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.
Kopelli
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.
virtual_odin
thanks * 100000...!!!
you have save my life!!! hehe
really thank you very much friend.
Regards.
M.Forsyth
LitePipe
Arabinda.Net
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
Jus55
thank you very very much!!
now, I try do it. I hope that works.
thanks ;-)
anodize
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
DouglasJB
gordonk
JimmyV
I think you can test the value of SaveAsUi to see if the SaveAs dialog will be displayed for the user.
Regards
ADG
JonneeZ
please, I need some help. I cant find any solution for this :(
any idea
Thanks & Regards