Using Shell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vdraceil
    New Member
    • Jul 2007
    • 236

    Using Shell

    Consider,
    'Shell "C:\Program Files\Microsoft Office\Office10 \EXCEL.EXE" "C:\My Documents\Query .xls"'
    This would open Query.xls file in MS Excel for sure,but i have typed manually excel.exe's path in the code. The problem is that i have to run my application in any other computer and i cannot be sure that every computer would have installed excel in the very same path (or not installed at all..).
    So,with just knowing the name of the exe file how to find the correct installed path?
    (Searching all the drives and folders for excel.exe may be an option,but it may eat up our time and slow down the application)
    Anyone has got any alternative ideas?If so pls do share..
    All i want to do is open any file with any exe.
  • astalavista
    New Member
    • Mar 2009
    • 1

    #2
    I am not sure if this is going to help you.

    You can just try to open the excel file by giving file name. If excel is installed and registered on the machine, the file will open by its own.

    or you can use the Process class

    Process p = new Process();
    p.StartInfo.Fil eName = "excel";
    p.StartInfo.Arg uments = // Give full file name here
    p.Start();
    p.WaitForExit() ;


    make sure you included System.Diagnost ic namespace for Process class.

    Comment

    • vdraceil
      New Member
      • Jul 2007
      • 236

      #3
      I'm using vb6..I should have mentioned it..i'm sorry
      is it .net code?

      Comment

      Working...