[英]How to save as an excel workbook and open the saved workbook
我有下面的代碼保存為 excel 工作簿。 我遇到的問題是將其保存到文件夾中,但不會繼續保存文件作為當前打開的 excel 工作簿。
With Application.FileDialog(msoFileDialogSaveAs)
.Title = "Save schedules to specified folder"
.ButtonName = "Save Schedules"
.InitialFileName = "schedules"
.Show
Application.DisplayAlerts = False
Application.EnableEvents = False
End With
我想要實現的是與 excel 中的保存相同的 function,您在其中保存並繼續使用保存的文檔
該程序沒有保存文件。 並且該文件仍應打開。 我將您的程序修改為
Application.DisplayAlerts = False
Application.EnableEvents = False
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
With fd
.Title = "Save schedules to specified folder"
.ButtonName = "Save Schedules"
.InitialFileName = "schedules"
.Show
End With
ActiveWorkbook.SaveAs fd.SelectedItems(1)
'wb1.SaveAs fd.SelectedItems(1)
'wb1.Activate
Application.DisplayAlerts = True
Application.EnableEvents = True
然后可以保存文件。 您可能需要將 select 文件類型設置為 xlsm 才能正確保存。 在 Filedialog 中添加過濾器可能會更好。 如果要保存的工作簿不是活動工作簿,你可以修改這部分,也許保存后激活工作簿,一切由你決定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.