If you are using a less than about nine year old version of WinBatch there is nothing special about passing a COM Automation object to a subroutine.

I tried your example and if the subroutine was passed valid information it worked the same way the workbook object member from the mainline script did. If the subroutine was passed invalid information it failed the same way the main line version failed with the same information.

You might want to run your script in the WinBatch Studio debugger and examine the variable values as you step though your script. You may find that you are stepping on a variable or not initializing a variable or whatever.

Logged

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight." - Dr. Tom Cade

Interesting. Although the error takes place on the line where we are assigning the worksheet, it's actually referring to a subsequent line, the 7th line in the procedure. This happens, even if we put breakpoints on each line, before that line; the error still occurs on the first line in the procedure.

In 2011 and 2012, I developed an application that freely passed around a COM object, in some cases three or four calls deep into a call stack. The application gave me plenty of challenges, but losing access to the COM object wasn't among them.