- Workbooks.add方法新建一个工作簿,ActiveWorkbook引用该工作簿,SaveAs 另存为其他路径。
Sub 新建工作簿()
Workbooks.Add'新建工作簿
'工作簿另存到其他路径, \ 后面是工作簿名称:小强.xlsx
ActiveWorkbook.SaveAs Filename:="C:\Users\Administrator\Desktop\vba笔记\15.操作工作簿\小强.xlsx"
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="C:\Users\Administrator\Desktop\vba笔记\15.操作工作簿\小李.xlsx"
Workbooks("小李.xlsx").Activate '激活小李这个工作簿
'此时两个工作簿都是打开的
End Sub
Sub 新建工作簿1()
Dim wkb1 As Workbook
Dim wkb2 As Workbook
Set wkb1 = Workbooks.Add '新建工作簿
Set wkb2 = Workbooks.Add
wkb1.Activate '激活工作簿
wkb2.SaveAs Filename:="C:\Users\Administrator\Desktop\vba笔记\15.操作工作簿\小雄.xlsx" '工作簿另存为其他路径上
End Sub
网友评论