Page 1 of 1

bat file to open workbook

Posted: 25 Dec 2022 08:29
by manios.anastasios
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

Re: bat file to open workbook

Posted: 27 Dec 2022 05:04
by miskox
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