[font=Times New Roman]دوستی سوال فرمودند:
برای این کار کافی است که کد زیر را در فایل اکسل در قسمت workbook کپی کنید:
Dim ISSAVEAS As Boolean
Private Sub Workbook_Activate()
ISSAVEAS = False
End Sub
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
If Success = True Then
MsgBox ("saved")
Else
MsgBox ("not saved")
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ISSAVEAS = False Then
Sheet1.Range("B1").Calculate
Dim str As String
str = Sheet1.Range("B1").Value
str = Replace(str, "/", "_")
str = Replace(str, " ", "_")
str = ActiveWorkbook.Path + "\" + Replace(str, ":", "_")
ISSAVEAS = True
ActiveWorkbook.SaveAs (str + ".xlsm")
ISSAVEAS = False
Cancel = True
End If
End Sub
یک فایل هم آماده کردم :
http://www.mediafire.com/view/?tvy8gguwmw3d8lk
موفق باشید.
نوشته اصلی توسط hajih[/font
برای این کار کافی است که کد زیر را در فایل اکسل در قسمت workbook کپی کنید:
Dim ISSAVEAS As Boolean
Private Sub Workbook_Activate()
ISSAVEAS = False
End Sub
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
If Success = True Then
MsgBox ("saved")
Else
MsgBox ("not saved")
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ISSAVEAS = False Then
Sheet1.Range("B1").Calculate
Dim str As String
str = Sheet1.Range("B1").Value
str = Replace(str, "/", "_")
str = Replace(str, " ", "_")
str = ActiveWorkbook.Path + "\" + Replace(str, ":", "_")
ISSAVEAS = True
ActiveWorkbook.SaveAs (str + ".xlsm")
ISSAVEAS = False
Cancel = True
End If
End Sub
یک فایل هم آماده کردم :
http://www.mediafire.com/view/?tvy8gguwmw3d8lk
موفق باشید.
کامنت