Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Sep 2001
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How 2 Run Xl From Bat file and .. (Xl '97 up)

    How can I run Excel from a bat file and tell it which macro to run PLUS pass a string that I can get to from the macro ?

    My concept of the contents of the bat file would go something like:

    WorkBookName.xls!Macro_Name_Here, "String Here"

    Then when the bat file is double clicked the workbook will open; Macro_Name will run automatically and the code within Macro_Name:

    Sub Macro_Name( passedString as string)

    msgbox passedstring

    end sub

    Short of all of that. How can I start a workbook and just tell it which macro to run and put that into a bat file?

    Thanks in advance!

    dingo

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How 2 Run Xl From Bat file and .. (Xl '97 up)

    To answer your last question:

    The conventional way to do this since XL 97 is to use a Workbook_Open event to run the code.

    You can call the WB which contains that code either by double clicking it or running a batch file something like:

    Excel.exe "c:my documentsDataMyWorkbook.xls"

    See Startup Switches under Help.

    I don't know how to easily pass the macro an additional startup switch, unless you use the File I/O capabilities to read the batch file text; that will take some work.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Star Lounger
    Join Date
    Sep 2001
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How 2 Run Xl From Bat file and .. (Xl '97 up)

    Thanks John!

    Yes I can handle that!

Posting Permissions

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