bat file to open workbook

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
manios.anastasios
Posts: 1
Joined: 25 Dec 2022 08:26

bat file to open workbook

#1 Post by manios.anastasios » 25 Dec 2022 08:29

i dont know if this topic is the right for my thread
i have a bat file that open my workbook that is in a removable usb
it work fine especially i have made an exe that run the bat file so all good
but now i made a change to filename of my workbook i add beside of the main name a number considering like a version
so my name was test and my bat was opening but now is test1 so cant find the workbook to open it
but tomorrow it might be test2 or test3 next day test4 and so on.
the code is

Code: Select all

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c test.bat"
"\test\test.xlsb"
any help how to make it see the main word test and like? i tried to put a quote as * but didn't work
if there is another way to do i am glad to hear your suggestions

miskox
Posts: 553
Joined: 28 Jun 2010 03:46

Re: bat file to open workbook

#2 Post by miskox » 27 Dec 2022 05:04

You could try this (based on the info I have):

Create run_xlsB.cmd (or name it as you wish) in the same folder where your .xlsb files are:

Code: Select all

@for /f "usebackq" %%f in (`dir /on /b *.xlsb`) do %%f
or

Code: Select all

@for /f "usebackq" %%f in (`dir /on /b *.xlsb`) do start "" %%f
See HELP CMD for other options if required.

This will search for *.xlsb files. You could change this to test*.xlsb if you wish. You could add path (test\*.xlsb for example).

Saso

Post Reply