PDA

View Full Version : Not sure Excel issue or Batch file issue - Application.Workbooks("Book2.xls").Close



justinferns
10-03-2011, 11:46 AM
Hi

I've got an issue but not sure if it's related to excel or to the batch code I use.

I'm using a batch file so that I can schedule a process to run the file "Book1.xls".

When I run the batch file, which opens Book1.xls, it gives me this error when I use the code Application.Workbooks("Book2.xls").Close {where I use Book1.xls to close the (already) open excel Book2.xls}

But when I run Book1.xls by double-clicking and enabling macros, it runs perfectly.

Any ideas in terms of batch code? This is the code I'm using:

@echo off

echo off

SET PROD_Folder=S:\General\Team\

"C:\Program Files\OFFICE11\EXCEL.EXE" "E:\Excel_Practise\Book1.xls" /p".\" /e

echo Copy to prefered location!

copy "E:\Excel_Practise\Book2.xls" "%PROD_Folder%Book2.xls"

echo DONE!

exit

* My excel code saves the file Book1.xls and places it as Book2.xls at the "PROD_Folder" location.

Can anyone help me on this?

Justin

mikerickson
10-07-2011, 10:37 PM
Im not sure what language that code is in, but the file path looks like a Windows file path.

shrivallabha
11-19-2011, 06:37 AM
Although, I am not a Mac user, the code written seems familiar to me. It is written for DOS.

The problem seems to be with the startup switches he has selected. Here they have been listed:
http://support.microsoft.com/kb/291288