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++.
#include <cstdlib>
#include <iostream>
usingnamespace 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.