Loading a file into excel using shell command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davidholmes
    New Member
    • Apr 2010
    • 3

    Loading a file into excel using shell command

    I need to load a csv file into excel with the shell command. My code works fine as long as excel is not already running but if there is another instance of excel open the shell command opens a new excel but does not load the csv file. I have not been able to find any list of command line switches for the shell command and wonder if this is the problem. The code I am using at the moment is

    Dim RetVal
    RetVal = Shell("C:\Progr am Files\Microsoft Office\OFFICE11 \excel.exe /e .\billcsv.csv", 1)
    AppActivate RetVal

    The Dim RetVal and AppActivate RetVal don't seem to be necessary.

    Any ideas?
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    There are command line switches for excel, see http://office.microsoft.com/en-us/ex...580301033.aspx

    Comment

    • davidholmes
      New Member
      • Apr 2010
      • 3

      #3
      Thanks for the link - I didn't know about it. The different switches don't help my problem unfortunately. The file will still not load if there is already an instance of Excel running - I just get a blank sheet. Do you think this is a VB6 shell command issue or an Excel issue?

      Comment

      • davidholmes
        New Member
        • Apr 2010
        • 3

        #4
        I have been playing around with this more and the problem seems to be reloading the file into a new instance of Excel if the file has been closed in its original instance but the instance is still running! The Process ID returned by the Shell command is different but for some reason a new instance of Excel will not load the file until the original instance has been closed completely. Is this a bug in Excel or is there a logical reason for this behaviour?

        Comment

        Working...