MEUserII
Board Regular
- Joined
- Oct 27, 2017
- Messages
- 91
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- Platform
- Windows
I am trying to write a VBScript (.vbs file) that will allow me to activate the current Excel window opened which is just the default "Book1" window after clicking "Blank Workbook" after opening Excel 2016 running on my Windows 10 PC, and activate that Window by bringing it on top (like as if I clicked on that window).
So, far I have only the following VBScript code:
Which I was able to create from the Microsoft Support Documentation here: https://support.microsoft.com/en-us...eobject-behavior-of-office-automation-servers
However, I believe my above code doesn't work because it just retrieves "Microsoft Excel" for the name of the window instead of "Book1" as shown below using MessageBox in VBScript to see the output.
So, how would I be able to activate this instance of Excel by retrieving the name "Book1"?
I want to know how to retrieve the window name of the Excel window that is open (for any Excel window open) for using with AppActivate that way I can generalize this code to working with any given already open Excel windows instead of always manually entering the window name, like entering "Book1" in the VBScript example below:
So, far I have only the following VBScript code:
Code:
CreateObject("Wscript.Shell").AppActivate GetObject(, "Excel.Application").Name
Which I was able to create from the Microsoft Support Documentation here: https://support.microsoft.com/en-us...eobject-behavior-of-office-automation-servers
However, I believe my above code doesn't work because it just retrieves "Microsoft Excel" for the name of the window instead of "Book1" as shown below using MessageBox in VBScript to see the output.
Code:
Dim ABCD
WScript.Sleep (1*1000)
ABCD=MsgBox(GetObject(, "Excel.Application").Name, 1, "MACRO STATUS")
So, how would I be able to activate this instance of Excel by retrieving the name "Book1"?
I want to know how to retrieve the window name of the Excel window that is open (for any Excel window open) for using with AppActivate that way I can generalize this code to working with any given already open Excel windows instead of always manually entering the window name, like entering "Book1" in the VBScript example below:
Code:
CreateObject("Wscript.Shell").AppActivate("Book1")
Last edited: