company logo

Call creating MS Office document

In order to call creating an MS Office document, MS Word has to be invoked. Since the technology for creating MS Office documents is based on MS Word macros (VB Script), the template document has to be called and executed. Since this is a different process, an ini-file has to be created and passed to the MS Word template (macro).

All information requested is passed via an ini-file, which is usually hard-coded in the document template macro. The document template examples provided in the .tpl directory of the installation folder shows how to open a database by means of an ini-file.

When calling an MS Office template (.dot), the location for the template file has to be passed to the function call (GetTemplatePath() is just a symbolic function call in the example, which returns the complete path for the document template file). Other option file variables as location for output file or root object instance for document have to be set in additional option variables as requested by the document template.

// generate document in separate process

bool ...fragment(Property &ph) {

// root object instance is selected in ph

// create ini-file for CreateDocument

  fstream ini_file;

  ini_file.open ("test.ini", fstream::out | fstream::app);

  ini_file << "[SYSTEM]" << std::endl;

  ini_file << "DICTIONARY=" << Option("SYSDB").toString().data() << endl;

  ini_file << "[DOCU]" << std::endl;

  ini_file << "DICTIONARY=" << Option("SYSDB").toString().data() << endl;

  ini_file << "RESOURCES=" << Option("RESDB").toString().data() << endl;

  ini_file << "DATABASE=" << Option("DATDB").toString().data() << endl;

  ini_file << "ONLINE_VERSION=YES" << endl;

  ini_file << "ACCESS_MODE=Write" << endl;

  ini_file << "NET=YES" << endl;

  ini_file << "ODABA_ROOT=" << Option("ODABA_ROOT").toString().data() << endl;

  ini_file << "CTXI_DLL=" << Option("CTXI_DLL").toString().data()<< endl;

  ini_file << "TRACE=" << Option("TRACE").toString().data() << endl;

  ini_file << "DSC_Language=" << Option("DSC_Language").toString().data()  endl;

// create option variables for template options

  ini_file.close();

  odaba::String   path(Option("ODABA_ROOT"));

  path += "/CreateDocument.exe";

// depending on template reqirements additional optione might be set

  ph.instanceContext().executeShell("open",GetTemplatePath());

  

  return true;

}

Notes:

In the example above, the the document template has to "know", where the ini-file has been stored.