open a WORD doc or EXCEL Sheet with C++

Hello,

I just need to open a WORD.doc or EXCEL sheet with a C++ function.
(no reading or writing, just open it)

I guess I need a function with the doc name/adress as parameter.
I already have a C# method - but for a application, which is not
.NET compatible, I need it in C++.


thanks

joachim

closed account (o3hC5Di1)
Hi there,

I'm sorry I can't provide you with a clear cut solution, but here's some reading material I found that might help you:

http://support.microsoft.com/kb/238393
http://msdn.microsoft.com/en-us/magazine/cc164042.aspx
http://support.microsoft.com/kb/178784


Hope that helps.

All the best,

NwN

This makes no sense; if you are not going to read the data in the file, or write to the file, why bother to open the file?

What do you mean by "open"?
If you simply wish to have the program make Word or Excel open the file specified by the user, you could always use this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    string path;
    string file;
    cout << "Please enter the path (location) of the file: ";
    cin >> path; // gets user input for location
    cout << "Please enter the file name (with extension): ";
    cin >> file; // gets file name
    
    string openString = "start " + path + "\\" + file; // the string for the command
    
    system(openString.c_str()); // sends the command and converts from type string to constant char

    system("PAUSE");
    return EXIT_SUCCESS;
}


This exact code will work, so system("PAUSE"); can be removed from the end if you so choose.

This will work with any file type, not just Word or Excel documents.

Hope this helped :)
Last edited on

Ok, thanks - that sounds good.

(with "just open" I meant, that there are no read/write operations in
C++ - of course the user may read the doc and write something...)


I will try it
^^ Thanks man! It really worKS!
No problem. Happy to help
Topic archived. No new replies allowed.