---
title: "WSH VBScript switch workSHEET in already open Excel workBOOK"  
description: "WSH VBScript switch workSHEET in already open Excel workBOOK"  
author: "Takeshi Okada"  
published: 2013-06-20  
updated: 2013-06-20  
canonical: https://www.mindstick.com/forum/1231/wsh-vbscript-switch-worksheet-in-already-open-excel-workbook  
category: "vb script"  
tags: ["vb script"]  
reading_time: 1 minute  

---

# WSH VBScript switch workSHEET in already open Excel workBOOK

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),\
\
Is it possible to [switch](https://www.mindstick.com/blog/104495/switch-bringing-new-advancements-in-the-education-management-system) worksheets within a workbook in a WSH VBScript (referenced by name) and if so, how would I do it?\
\
This will be used in a [script](https://www.mindstick.com/interview/477/how-can-i-execute-a-php-script-using-command-line) that [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) [opens](https://www.mindstick.com/news/2570/china-s-new-space-station-opens-for-business-in-an-increasingly-competitive-era-of-space-activity) an [Excel](https://www.mindstick.com/articles/12937/how-to-import-excel-data-in-sql-server-2014) file. I want to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) a worksheets called "[Version Control](https://www.mindstick.com/articles/333367/version-control-best-practices-with-tfs)".\
\
The following is how I am opening the workbook:\
\
xlsFile = path & "\xml-sitemap.xls"\
Set objExcel = WScript.CreateObject("Excel.Application")\
objExcel.Workbooks.open(xlsFile)\
\
Any help on above is really appreciated.

## Replies

### Reply by Sumit Kesarwani

Hi Takeshi,\
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](https://www.mindstick.com/articles/12845/things-to-remember-while-migrating-odoo-to-a-better-version) [Control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control)") 'ws is a Worksheet object**\


---

Original Source: https://www.mindstick.com/forum/1231/wsh-vbscript-switch-worksheet-in-already-open-excel-workbook

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
