Link to home
Start Free TrialLog in
Avatar of WeThotUWasAToad
WeThotUWasAToad

asked on

Make a file test.vbs using vbscript

Hello,

This is a bit embarrassing but a while back I received a solution from an expert but now I can't remember how to use it.

The thread is here:
https://www.experts-exchange.com/questions/28955794/Create-a-list-of-all-sheet-tab-names-in-a-given-Excel-workbook.html

I understand how to copy & paste the code :) and how to "change line 3" to my Excel filename but I don't know how to do this:
Using vbscript, make a file test.vbs with this code:

or this
Run it…
cscript /nologo test.vbs

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WeThotUWasAToad
WeThotUWasAToad

ASKER

Thanks a bunch Joe. That did the trick.

After following your steps, the list of sheet tab names appeared in the command prompt window. So now the question I have is:

How do I get that list into a text file so it's usable?

I tried double-clicking the test.vbs file thinking the list might be there but that resulted in a long sequence of small message boxes (one for each sheet tab name).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahhh, that puts me on familiar ground Joe.

I've never used AHK for something like this before so I'm doubly happy because you have given me several new commands to learn.

I did recognize enough of the script you posted to get the job done so now I've got a great new tool in my bag of tricks.

I sometimes find myself with more Excel worksheet tabs than I can keep track of. So in those cases, I like to create an Index sheet and then use =HYPERLINK() to create links to all the other tabs. Getting the list of sheet tab names in the first place is the first step so this will save me a bunch of time.

Thanks as always for your solid and well-explained comments.
You're very welcome, Steve. The Component Object Model (COM) native support is excellent in AHK. The documentation for it begins here:
https://autohotkey.com/docs/commands/ComObjActive.htm

The doc is good, with many examples, but an even better place to start learning about it is kon's tutorial, MS Office COM Basics:
https://autohotkey.com/boards/viewtopic.php?f=7&t=8978

You may use COM for more than just Excel, including Outlook, PowerPoint, Publisher, and Word. For example, here's an EE thread that I'm participating in where I wrote an AHK script that utilizes Word's COM calls:
https://www.experts-exchange.com/questions/28970468/Software-to-count-how-many-instances-of-words.html

As you noted, COM is a great new tool to have in your bag of tricks! Regards, Joe