Excel VBA 创建和关闭 Application 实例

创建 Excel 应用实例 'create new excel application object Set app = New Excel.Application 'set the applications visible property to false app.Visible = False '默认就是隐藏窗口。可以省略掉此行奢者 关闭 Excel 应用实例 'close the application app.Quit 'release outstanding object references Set app = Nothing

VBA 检查表名称是否存在

Function ExistSheetName(name As String) Dim sht As Worksheet For Each sht In Worksheets If sht.name = name Then ExistSheetName = True Exit Function End If Next ExistSheetName = False End Function

Excel VBA 添加新工作簿

' 创建工作簿, Dim newWb As Workbook '或在另一个应用实例(进程)中创建 Dim newWb as appExcel.Workbook ? Set newWb = Workbooks.Add 如果要给工作簿命名,只有在保存时,指定文件名。 wb.SaveAs Filename:="NewWB"