在桌面上使用工作簿名称和当前日期强制保存打开的工作簿
Forcefully save workbook on open with workbook name and current date on desktop
我需要一个宏来保存 excel sheet 每当在桌面上使用工作簿名称和当前日期打开时。
此外,如果桌面上存在相同的名称,即工作簿名称和当前日期宏不应 运行(以避免覆盖)。
请帮助编辑我的以下代码:
Sub SaveInFormat()
Application.DisplayAlerts = False
Workbooks.Application.ActiveWorkbook.SaveAs Filename:="I:\CAP_Profile\Desktop\" & Format(Date, "yyyymm") & "DB" & ".xls", leFormat:=51
Application.DisplayAlerts = True
End Sub
打开工作簿时保存它使用工作簿打开子:
Private Sub Workbook_Open()
End Sub
然后要获取桌面路径,请使用特殊文件夹。
Dim path As String
path = CreateObject("WScript.Shell").specialfolders("Desktop")
要检查文件是否存在于桌面上,请使用类似这样的东西(DirFile 是指向文件确切路径的字符串):
If Len(Dir(DirFile)) = 0 Then
''Go ahead and save it
Else
End
End If
我需要一个宏来保存 excel sheet 每当在桌面上使用工作簿名称和当前日期打开时。 此外,如果桌面上存在相同的名称,即工作簿名称和当前日期宏不应 运行(以避免覆盖)。
请帮助编辑我的以下代码:
Sub SaveInFormat()
Application.DisplayAlerts = False
Workbooks.Application.ActiveWorkbook.SaveAs Filename:="I:\CAP_Profile\Desktop\" & Format(Date, "yyyymm") & "DB" & ".xls", leFormat:=51
Application.DisplayAlerts = True
End Sub
打开工作簿时保存它使用工作簿打开子:
Private Sub Workbook_Open()
End Sub
然后要获取桌面路径,请使用特殊文件夹。
Dim path As String
path = CreateObject("WScript.Shell").specialfolders("Desktop")
要检查文件是否存在于桌面上,请使用类似这样的东西(DirFile 是指向文件确切路径的字符串):
If Len(Dir(DirFile)) = 0 Then
''Go ahead and save it
Else
End
End If