+ Reply to Thread
Results 1 to 6 of 6

Execute a macro from command line: possible or not ?

  1. #1
    Drinkmilk
    Guest

    Execute a macro from command line: possible or not ?

    Hello,

    I would like to know wether it is possible to run a macro in command line
    mode for Excel. After having searched in the Web and on this forum, I have
    seen several comments saying that it is impossible. I am very surprised
    because this is possible with Word, using for example:
    "C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
    /mFileOpenAndRepair

    Can you confirm if really this is not possible with Excel ?

    Many thanks



  2. #2
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360
    can you not fire the macro with a workbook_open event?

  3. #3
    Peter Rooney
    Guest

    RE: Execute a macro from command line: possible or not ?

    Mr/Ms Milk,

    I don't know the answer, but why would you want to run code on opening in
    this manner when you can do it by making it part of your workbook_open macro?

    Regards

    Pete

    "Drinkmilk" wrote:

    > Hello,
    >
    > I would like to know wether it is possible to run a macro in command line
    > mode for Excel. After having searched in the Web and on this forum, I have
    > seen several comments saying that it is impossible. I am very surprised
    > because this is possible with Word, using for example:
    > "C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
    > /mFileOpenAndRepair
    >
    > Can you confirm if really this is not possible with Excel ?
    >
    > Many thanks
    >
    >


  4. #4
    papou
    Guest

    Re: Execute a macro from command line: possible or not ?

    Hello Drinkmilk
    This is possible using a script.
    Paste this into a new text file and amend accordingly.
    Save with .VBS suffix and double-click to run.

    Dim objxl, xlwbk
    Set objxl = CreateObject("Excel.Application")
    objxl.Visible = True
    Set xlwbk = objxl.Workbooks.Open("C:\Documents and Settings\papou\My
    documents\Sample1.xls")
    objxl.Run ("Go")

    HTH
    Cordially
    Pascal


    "Drinkmilk" <[email protected]> a écrit dans le message de
    news: [email protected]...
    > Hello,
    >
    > I would like to know wether it is possible to run a macro in command line
    > mode for Excel. After having searched in the Web and on this forum, I have
    > seen several comments saying that it is impossible. I am very surprised
    > because this is possible with Word, using for example:
    > "C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
    > /mFileOpenAndRepair
    >
    > Can you confirm if really this is not possible with Excel ?
    >
    > Many thanks
    >
    >




  5. #5
    Drinkmilk
    Guest

    Re: Execute a macro from command line: possible or not ?

    Thanks for your answers guys.

    Papou, your example allow me to run the macro that is "auto-run" in the
    sample1.xls file, does'nt it ?

    Actually, I have written a macro in a .xla file, it contains a function that
    open a file with the "Open and repair" option when it is called. I have put
    this macro in the XLStart folder so that it is loaded each time Excel is
    opened. In some specific context, I would like to call my function, so not
    systematically. As I said in my first post, this is very easy with Word, but
    I still did not found the way to do it with Excel.

    Sorry if was not clear with py first post, I hope it is better now.


    "papou" wrote:

    > Hello Drinkmilk
    > This is possible using a script.
    > Paste this into a new text file and amend accordingly.
    > Save with .VBS suffix and double-click to run.
    >
    > Dim objxl, xlwbk
    > Set objxl = CreateObject("Excel.Application")
    > objxl.Visible = True
    > Set xlwbk = objxl.Workbooks.Open("C:\Documents and Settings\papou\My
    > documents\Sample1.xls")
    > objxl.Run ("Go")
    >
    > HTH
    > Cordially
    > Pascal
    >
    >
    > "Drinkmilk" <[email protected]> a écrit dans le message de
    > news: [email protected]...
    > > Hello,
    > >
    > > I would like to know wether it is possible to run a macro in command line
    > > mode for Excel. After having searched in the Web and on this forum, I have
    > > seen several comments saying that it is impossible. I am very surprised
    > > because this is possible with Word, using for example:
    > > "C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
    > > /mFileOpenAndRepair
    > >
    > > Can you confirm if really this is not possible with Excel ?
    > >
    > > Many thanks
    > >
    > >

    >
    >
    >


  6. #6
    DavidAtCaspian
    Guest

    Re: Execute a macro from command line: possible or not ?

    I wonder if this would be OK for me too?

    I have a spreadsheet with a couple of command buttons, neither of which I
    want to run automatically. BUT I DO want, at a scheduled time, to open Excel
    and run one of the buttons (at different times and under different
    circumstances.)
    - One button is a raw data import from six other spreadsheet, which I want
    to run early in the morning so the sheet is ready when people get to work.
    The other is an export, which I want to run when everybody has finished for
    the day . I tried doing all the work in Access, but the machine runs out of
    resources because it has to keep Access AND Excel open.


    It looks as though the code sent by papou should do the job, just by putting
    in the right vba sub name.

    Is there an editor like vba that will give me autocorrection/debug
    capability, or am I limited to something like notepad, and running the whole
    thing and hoping?
    The actual code takes about 30 minutes to run.

    It does seem odd that Microsoft has given us command line switches in the
    other Office Applications, but not Excel, where it would be more useful than
    it is in Word. Judgiing by various threads I've just read, there is a big
    demand for this functionality. Probably more than there is for hidden flying
    games.




    "papou" wrote:

    > Hello Drinkmilk
    > This is possible using a script.
    > Paste this into a new text file and amend accordingly.
    > Save with .VBS suffix and double-click to run.
    >
    > Dim objxl, xlwbk
    > Set objxl = CreateObject("Excel.Application")
    > objxl.Visible = True
    > Set xlwbk = objxl.Workbooks.Open("C:\Documents and Settings\papou\My
    > documents\Sample1.xls")
    > objxl.Run ("Go")
    >
    > HTH
    > Cordially
    > Pascal
    >
    >
    > "Drinkmilk" <[email protected]> a écrit dans le message de
    > news: [email protected]...
    > > Hello,
    > >
    > > I would like to know wether it is possible to run a macro in command line
    > > mode for Excel. After having searched in the Web and on this forum, I have
    > > seen several comments saying that it is impossible. I am very surprised
    > > because this is possible with Word, using for example:
    > > "C:\Program Files\Microsoft Office\OFFICE11\WinWord.exe" "c:\MyDoc.doc"
    > > /mFileOpenAndRepair
    > >
    > > Can you confirm if really this is not possible with Excel ?
    > >
    > > Many thanks
    > >
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1