open excel-file

This is a discussion on open excel-file within the C Programming forums, part of the General Programming Boards category; hello im trying to open an .xls file from my program with system("C:\PROGRAM\Microsoft Office\Office\excel.exe myfile.xls") Problem is, it doesnt like ...

  1. #1
    Unregistered
    Guest

    open excel-file

    hello

    im trying to open an .xls file from my program with

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

    Problem is, it doesnt 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 wont work..

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

  5. #5
    Unregistered
    Guest
    yup, ive include stdlib.h and Im sure its 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 its my computor, cuz it still wont work

    Ive 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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,764
    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, im 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,789
    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 its 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, 09:39 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07: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, 10:54 AM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21