Developer Documentation Library > Data Model > UNICOM Intelligence Data Model samples > UNICOM Intelligence Data Model-related sample code > Word macros to clean text responses
 
Word macros to clean text responses
These macros allow you to use the functionality within Microsoft Word to clean verbatim text responses collected in UNICOM Intelligence Interviewer projects. For example, you can correct spelling mistakes, remove erroneous characters, expand abbreviations, and so on.
You use the first macro to import the text responses from your project to a Word document. When you have finished using Word to clean the responses, you use the second macro to upload the responses back to your project.
Installing the Word macros
The UNICOM Intelligence Developer Documentation Library includes a Word template file called Verbatim Response Cleanup Macros.dot, which contains the macros. To use the template, you must copy it as follows:
From:
[INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Code\General\Word
To:
C:\Documents and Settings\<Windows user name>\Application Data\Microsoft\Templates
Importing text responses into a Word document
1 Start Word and from the File menu, choose New. The New Document pane opens.
2 Under Templates, click On my computer. The Templates dialog opens.
3 Select Verbatim Response Cleanup Macros.dot and click OK. A blank Word document opens.
4 From the Word menu, choose: Developer > Macro
5 In the Macros dialog, select GetTextResponsesFromDatasource and click Run.
This opens the Data Link Properties dialog.
6 In Metadata, click Browse and select the questionnaire definition (.mdd) file for the project that you want to import. Questionnaire definition files are typically under folder SPSSMR_FMROOT\Shared\Projects.
7 Optional. To select the metadata version, click Properties.
8 In the Data Link Properties dialog, click OK.
The Select Variables dialog opens and displays all the text variables for the project.
9 To select the variables that you want to import, click the check boxes.
10 When the variables are displayed in the Word document, they can be grouped by variable or by respondent. Select Group by variable or Group by respondent as required.
11 If you want the import to include any empty or Null responses, select Display empty responses.
12 Click OK.
For the variables that you have selected, the text responses are added to the Word document.
Cleaning the responses
Use the functionality within Word to clean the text responses. You might want to correct the responses manually, or use the Spelling and Grammar checker, or write a macro to apply your own custom rules.
Important: Make sure that you only make changes within the border surrounding each response. If you accidently change the Word document outside of the borders, you might not be able to upload the responses back to your project.
Like any other Word document, you can save the document and open it again at a later date. The connection string for your project is stored in the document.
Uploading the responses to the project
1 Open your Word document, and then click Developer > Macro
2 In the Macros dialog, select UpdateDatasource, and then click Run.
All the responses in your document are uploaded to the project that you imported them from.
Requirements
UNICOM Intelligence Data Model
Microsoft Word 2007 or higher
See also
Data Link Properties dialog
UNICOM Intelligence Data Model-related sample code