本文介绍了WSH VBScript 在已经打开的 Excel workBOOK 中切换 workSHEET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 WSH VBScript(按名称引用)中的工作簿中切换工作表,如果可以,我该怎么做?
Is it possible to switch worksheets within a workbook in a WSH VBScript (referenced by name) and if so, how would I do it?
这将用于已打开 Excel 文件的脚本中.我想访问一个名为版本控制"的工作表.
This will be used in a script that already opens an Excel file. I want to access a worksheets called "Version Control".
以下是我打开工作簿的方式:
The following is how I am opening the workbook:
xlsFile = path & "\xml-sitemap.xls"
Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Workbooks.open(xlsFile)
推荐答案
This will do it(根据 Ekkehard.Horner 的评论修改)
This will do it (amended following Ekkehard.Horner's comment)
Dim ws
Dim wb
xlsFile = path & "\xml-sitemap.xls"
Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Workbooks.open(xlsFile)
Set wb = objExcel.ActiveWorkbook 'the ActiveWorkbook will refer to the opened workbook
Set ws = wb.Worksheets("Version Control") 'ws is a Worksheet object
这篇关于WSH VBScript 在已经打开的 Excel workBOOK 中切换 workSHEET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!