Open excel hidden w/VBS script

tx12345

Board Regular
Joined
Aug 28, 2006
Messages
165
i came acros this code on the board:

on error resume next
set app = createobject("excel.application")
set wb = app.workbooks.open (replace(wscript.scriptfullname,wscript.scriptname,"hello.xls"))
if wb is nothing then app.quit

it opens an excelfile while keepig excel completely hidden. pretty cool.

but i have about 8 interactive files and once one of them tries to open the prog quits.

is there a way to modify this script to account for the possibility of other files that might come into play?

TIA!


tx
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

jdavis9

Active Member
Joined
Mar 8, 2002
Messages
337
you can always
set app = Getobject(, "excel.application") ' use already open excel
app.visible = false

after opening another workbook
 

tx12345

Board Regular
Joined
Aug 28, 2006
Messages
165
maybe an example will help

here are the files:

hello.xls
goodbye.xls
hello.vbs

place all three files in the same folder. ok, so you''ll see if you open hello.xls directly from excel, everything works fine, as the Run macro does some processing in hello and goodbye, and finally ends up at goodbye.

but if you open with the hello.vbs file, which eliminates the big excel splash - even if only for a second - and run the routine, everything seems to work, and you even see the userform header for the goodbye file, but then once the macro is done, the application quits.

i tried to add your code, but could not figure out where it should go.

thanks for the reply


tx
 

tx12345

Board Regular
Joined
Aug 28, 2006
Messages
165
sorry about that. guess the links were only good for that day or something. i changed the links so (if you want) you can access the files now.

thanks again

tx
 

Forum statistics

Threads
1,137,300
Messages
5,680,699
Members
419,928
Latest member
dolincasting

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top