VBA添加新的表在一个封闭的excel没有开放&获取工作表名称已添加? [英] VBA to add new sheet in a closed excel without opening & get the sheet name added?
本文介绍了VBA添加新的表在一个封闭的excel没有开放&获取工作表名称已添加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个excelClosed.Xls,目前没有打开。
I have an excel "Closed.Xls" which is not opened currently.
请让我知道如何在这个封闭的excel文件中添加新的工作表。我知道如何在当前excel中添加新的表格。
Please let me know how to add new sheets in to this closed excel file. I know how to add new sheets in current excel.
Dim WS as Worksheet
Set WS = Sheets.Add
请让我知道如何
- 使用VBA在封闭的excel中添加新的表格,
- 获取添加的工作表的名称
注意:我不想重命名工作表。
谢谢
推荐答案
要获取工作表名称,请使用工作表
变量,即
To get the sheet name use a worksheet
variable, ie
Sub Added()
Dim Wb As Workbook
Dim ws As Worksheet
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
Set Wb = Workbooks.Open("c:\Temp\closed.xls")
Set ws = Wb.Sheets.Add
Debug.Print ws.Name
Wb.Save
Wb.Close
With Application
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
这篇关于VBA添加新的表在一个封闭的excel没有开放&获取工作表名称已添加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文