Opening an existing table document
Sample script file: MyFirstTable.mrs
In
Creating a simple table of Age by Gender, the following line of script is used to save the table in a table document (.
mtd) file:
TableDoc.Save("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Output\MyFirstTable.mtd")
This saves details of the table structure in an XML file format. If the script includes a line to populate the table before saving the file, the .mtd file also includes the cell values for the populated table. After you have saved a table document, you can open it again using a script, or using UNICOM Intelligence Reporter - Survey Tabulation or UNICOM Intelligence Reporter. For example, you can set up a number of tables using UNICOM Intelligence Professional Tables Option, save the tables as an .mtd file, and then upload the file into a project in UNICOM Intelligence Reporter - Survey Tabulation that uses the same data source so that it can be accessed by multiple users. Alternatively, you can open the table document file using UNICOM Intelligence Reporter, change the tables, and then upload the file to UNICOM Intelligence Reporter - Survey Tabulation.
For information on how to open table documents from UNICOM Intelligence Professional in UNICOM Intelligence Reporter - Survey Tabulation or Survey Reporter, see the UNICOM Intelligence Reporter - Survey Tabulation User's Guide or the UNICOM Intelligence Reporter User's Guide.
To open a table document using a script
To open an .mtd file using a script, you can use the Document.Open method. For example:
Set TableDoc = CreateObject("TOM.Document")
TableDoc.Open("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Output\MyFirstTable.mtd")
By default, any results saved with the .mtd file are automatically loaded when you open the file. However, you might want to remove the results and repopulate the table using the latest data. To do this, you can add a second parameter when you open the file, to specify that any saved results are not loaded:
TableDoc.Open("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Output\MyFirstTable.mtd", 0)
This results in an empty table, so you also need to repopulate the table using the TableDoc.Populate() method.
When using the Open method with a previously saved .mtd file, you did not specify a data source. This information was stored in the .mtd file when it was originally saved. You might want to open a table document file using a different data source than the one with which you originally created it. For example, you can use the same set of tables on a number of different data sets that use the same variables, or set up tables using a test data source and then use the same tables on a live data source with a different name or in a different location. To do this, use the Document.OpenWithDataSet method to override the data source that is saved in the .mtd file:
TableDoc.OpenWithDataSet("[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\ Output\MyFirstTable.mtd", _
0, _
"[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Data\Xml\museum.mdd", _
, "[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Data\Xml\museum.xml", _
"mrXmlDsc")
If you open a table document file with a data source that is not identical to the one with which you created it, the tables might be invalid. Ensure that the new data source contains the same variables, with the same names and categories, as the original data source.
Requirements
UNICOM Intelligence Reporter
Next
See also