Information Systems



Calling Open Office from C++ on Windows

Calling Open Office from C++ on Windows.

I want to be able to do this to let my app users view tabular data in a spreadsheet format. I export to the Office 2003 xml format which Open Office reads.

The one thing that was giving me problems was that I was trying to use the application name in the first parameter for CreateProcess. I'm not even sure why Win32 needs the first parameter. It seems redundant. Anyway, use NULL there and it should work.

#if WIN32
STARTUPINFO si = {0};
si.cb = sizeof(si);
si.dwFlags = 0;
si.wShowWindow = SW_SHOW;
PROCESS_INFORMATION pi;
std::string app = "C:/Program Files/OpenOffice.org 2.2/program/soffice.exe";
std::string cl = app + " " + "c:/test.xml";
bool ok = CreateProcess(NULL, (char*) cl.c_str(), NULL, NULL, TRUE,
0, NULL, ".", &si, &pi);
#endif