Workbook 对象.close(SaveChanges,Filename,RouteWorkbook)关闭某个工作簿。其中:⚫ 所有参数均为可选参数。⚫ 参数 SaveChanges 指定是否保存对工作簿所作的修改。如果没有修改过工作簿,则忽略此参数。如果修改了工作簿,则使用此参数指定是否保存修改;如果参数值设置为 True,则关闭时将保存修改,此时如果工作簿...
下面的代码关闭工作簿test1.xlsx,并保存对该工作簿所作的修改。 Sub CloseAWorkbook() Workbooks("test1.xlsx").Close SaveChanges:=True End Sub 下面的代码关闭工作簿test1.xlsx,并将对该工作簿的修改保存到test2.xlsx工作簿中。 Sub CloseAWorkbook...
下面的代码关闭工作簿test1.xlsx,并保存对该工作簿所作的修改。 Sub CloseAWorkbook() Workbooks('test1.xlsx').Close SaveChanges:=True End Sub 下面的代码关闭工作簿test1.xlsx,并将对该工作簿的修改保存到test2.xlsx工作簿中。 Sub CloseAWorkbook1() Workbooks('test1.xlsx').Close SaveChanges:=True, ...
Close a Workbook without Saving If you want to save the active workbook without saving you need to use code like the following. ActiveWorkbook.Close SaveChanges:=False In this code, I have specified “False” for the “SaveChanges” argument. So, VBA will ignore any changes in the workbook t...
1 打开Excel表格,点击【开发工具】,【Visual Basic】打开VBA编辑器,也可以使用【Alt+F11】组合键打开VBA编辑器。2 点击VBA编辑器菜单栏上面的【插入】,【模块】。3 在VBA编辑器的代码框里面输入以下代码程序:Sub ExitWorkbook()On Error Resume Next '忽略运行过程中出现的错误Application.DisplayAlerts =...
Workbooks(Book_Name).Close SaveChanges:=FalseMessage:MsgBox"The Workbook is Already Closed",vbExclamationEndSub Visual Basic Copy Developing the Macro to Close a Workbook Without Saving Using Excel VBA ⧪ Method 1 – Opening the VBA Window ...
我们每天都要统计企业的生产量,但有时候可能还没有把数据录入完就点了关闭,就象下表这样下午的数据没有填,这时VBA会提醒我们数据未填完,并用光标选择该行进行提示。 每日生产情况统计表 Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next ...
1– begin the macro code by declaring theVBA Macro Code’sSubname. 2– theVBA Workbooksproperty takes theCloseandSave Changescommand of a specific Excel workbook. Go throughExample 1’sstepsto close and save the workbook. Checking Saved Files for Confirmation ...
However, it appears that OnTime events aren't fired if they are registered in a Workbook_Close event that was initiated by VBA with ClientWorkbook.Close. Emulate mouse: In the client book's Workbook_Close event, emulate a mouse click on the client book's front-end close-button. But ...
PrivateSubWorkbook_Open() SetXLApp =NewCExcelEvents EndSub 如果您尝试打开不同的工作簿,不起作用。如果你点击了PERSONAL.XLSB在最近的文档中,它将触发该消息。 将此移动到另一个ThisWorkbook对特定工作簿的对象,它仍然仅适用于该工作簿: PrivateXLAppAsCExcelEvents ...