Thread: open excel-file

  1. #1
    Unregistered
    Guest

    open excel-file

    hello

    i´m trying to open an .xls file from my program with

    system("C:\\PROGRAM\\Microsoft Office\\Office\\excel.exe myfile.xls")

    Problem is, it doesn´t like the space between Microsoft and Office

    any suggestions??

    Help plz!!

  2. #2
    Unregistered
    Guest
    Code:
    system("\"C:\\PROGRAM\\Microsoft Office\\Office\\excel.exe myfile.xls\"") ;

  3. #3
    Unregistered
    Guest
    I tried system("\"C:\\PROGRAM\\Microsoft Office\\Office\\excel.exe myfile.xls\"");
    but it still won´t work..

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Are you sure it's the right path, and that you've included stdlib?

  5. #5
    Unregistered
    Guest
    yup, i´ve include stdlib.h and I´m sure it´s the right path (dubbelchecked)


  6. #6
    Unregistered
    Guest
    You shouldnt have to specify the full path, not even mention "excel.exe" *.xls is associated with it and simply:
    Code:
    system("myfile.xls");
    should do it!
    I just tryed it and it works!

  7. #7
    Unregistered
    Guest
    system("myfile.xls");
    maybe it´s my computor, cuz it still won´t work

    I´ve also tried system("C:\\WINDOWS\\notepad.exe myfile.txt");
    and this work, but not system("myfile.txt");

    any ideas??

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Are you using some pre-DOS brain-damaged compiler which knows nothing of long filenames, spaces in filenames or how associations work?

  9. #9
    Unregistered
    Guest

    nope, i´m using VC++ on Win 98

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Originally posted by Unregistered
    Code:
    system("\"C:\\PROGRAM\\Microsoft Office\\Office\\excel.exe myfile.xls\"") ;
    Interesting. I would have thought PROGRAM would be PROGRAM FILES.

  11. #11
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    If you have a windows compiler (Borland Builder, MSVC++, Bloodshed.....) dump system and use ShellExecute()

    Code:
    #include <windows.h>
    
    int main(void){
    
    	ShellExecute(0,"open","Myfile.xls",NULL,NULL,SW_SHOWNORMAL);
    	
    	return 0;
    }
    Its more efficient. If you dont run it from the same directory, substitute "Myfile.xls" for "C:\\mydir\\Myfile.xls" or whatever

  12. #12
    Unregistered
    Guest
    thanx!

    now it´s working!


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Replies: 12
    Last Post: 03-10-2005, 07:48 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM