vba 创建新的 Excel 工作簿
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12352593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating a new excel workbook
提问by mezamorphic
Can someone please help me with the following code:
有人可以帮助我使用以下代码:
Dim NewOutputFile As Workbook
Set NewOutputFile = Workbooks.Add(FileName & ".xls")
where FileName = "C:\Documents and Settings\me\My Documents\file.xls"
在哪里 FileName = "C:\Documents and Settings\me\My Documents\file.xls"
I want to create a new workbook dynamically and then add new tabs:
我想动态创建一个新工作簿,然后添加新选项卡:
NewOutputFile.Sheets.Add ("New tab")
EDIT when I say "workbook" I mean a new excel file
编辑当我说“工作簿”时我的意思是一个新的 excel 文件
回答by gparis
NewOutputFile.Sheets.Add().Name= "New tab"
Or if you want to add a Worksheet as the last Worksheet:
或者,如果您想添加一个工作表作为最后一个工作表:
NewOutputFile.Sheets.Add(After:=NewOutputFile.Sheets(NewOutputFile.Sheets.Count)).Name = "New tab"