+ Reply to Thread
Results 1 to 4 of 4

Passing argument to Excel

  1. #1
    Bing
    Guest

    Passing argument to Excel

    Hello,

    I'm trying to programmatically, in one command line, to start excel with a
    user specified excel template and the template itself then automatically
    loads an arbitrary file, also specified in the same command line.

    I know that i can specify in one command line "..\excel.exe myTemplate.xlt"
    to have excel start and automatically load the template.

    But how can you also automaticaly have the template then load an arbitrary
    file from the SAME command line that started excel in the first place?
    ie. "..\excel.exe myTemplate.xlt c:\myFile.txt"

    Thanks

  2. #2
    Devin Linnington
    Guest

    RE: Passing argument to Excel

    This is easy, so don't worry about it. All you have to do is put "myFile.txt"
    in "c:\documents and settings\USER\aplication data\excel\xlstart\" . This
    folder might be under "c:\program files..." depending on your version of
    windows/office. When that .txt file is stored under that xlstart thing it
    will auto-load into excel whenever it is started. Also might want to change
    the .txt to .cvs so you don't have to go through the wizard thing that pops
    up when loading .txt files. (.cvs are comma delimited files). Hope that
    helps...

    P.S. I'm not sure if excel will auto-load non-.xls files, so you will just
    have to try it out and see

    "Bing" wrote:

    > Hello,
    >
    > I'm trying to programmatically, in one command line, to start excel with a
    > user specified excel template and the template itself then automatically
    > loads an arbitrary file, also specified in the same command line.
    >
    > I know that i can specify in one command line "..\excel.exe myTemplate.xlt"
    > to have excel start and automatically load the template.
    >
    > But how can you also automaticaly have the template then load an arbitrary
    > file from the SAME command line that started excel in the first place?
    > ie. "..\excel.exe myTemplate.xlt c:\myFile.txt"
    >
    > Thanks


  3. #3
    BW
    Guest

    RE: Passing argument to Excel

    Hello Devin

    Thanks for responding.

    That is an option too, but i was looking more at passing the filename as a
    command line argument to excel. I have a macro in the .XLT template that
    will load a file as long as it has the filename. But i haven't been able to
    read how to pass that filename to the template l via the command line ie.
    "excel.exe loadTemplate.XLT fname.txt"

    "Devin Linnington" wrote:

    > This is easy, so don't worry about it. All you have to do is put "myFile.txt"
    > in "c:\documents and settings\USER\aplication data\excel\xlstart\" . This
    > folder might be under "c:\program files..." depending on your version of
    > windows/office. When that .txt file is stored under that xlstart thing it
    > will auto-load into excel whenever it is started. Also might want to change
    > the .txt to .cvs so you don't have to go through the wizard thing that pops
    > up when loading .txt files. (.cvs are comma delimited files). Hope that
    > helps...
    >
    > P.S. I'm not sure if excel will auto-load non-.xls files, so you will just
    > have to try it out and see
    >
    > "Bing" wrote:
    >
    > > Hello,
    > >
    > > I'm trying to programmatically, in one command line, to start excel with a
    > > user specified excel template and the template itself then automatically
    > > loads an arbitrary file, also specified in the same command line.
    > >
    > > I know that i can specify in one command line "..\excel.exe myTemplate.xlt"
    > > to have excel start and automatically load the template.
    > >
    > > But how can you also automaticaly have the template then load an arbitrary
    > > file from the SAME command line that started excel in the first place?
    > > ie. "..\excel.exe myTemplate.xlt c:\myFile.txt"
    > >
    > > Thanks


  4. #4
    BW
    Guest

    RE: Passing argument to Excel

    Hello again,

    I should also add that i was able to achieve the above using Automation, ie:

    Set XLApp = CreateObject("Excel.Application")

    XLApp.Visible = True
    XLApp.workbooks.open XLApp.TemplatesPath & "Loader.xlt"

    XLApp.Run "Module1.Load", someFilename

    However, i'm trying to achieve the same thing via a command line ie. at a
    dos prompt, "excel.exe Loader.xlt someFilename" but i just can't seem to
    figure out how to pass someFilename either to excel or the Loader.xlt
    template.


    "Bing" wrote:

    > Hello,
    >
    > I'm trying to programmatically, in one command line, to start excel with a
    > user specified excel template and the template itself then automatically
    > loads an arbitrary file, also specified in the same command line.
    >
    > I know that i can specify in one command line "..\excel.exe myTemplate.xlt"
    > to have excel start and automatically load the template.
    >
    > But how can you also automaticaly have the template then load an arbitrary
    > file from the SAME command line that started excel in the first place?
    > ie. "..\excel.exe myTemplate.xlt c:\myFile.txt"
    >
    > 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