Consulting

Results 1 to 3 of 3

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

  1. #1

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

    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

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Im not sure what language that code is in, but the file path looks like a Windows file path.

  3. #3
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    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
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •