Changes

Including Check Boxes on an MS Word Merge Document

2,137 bytes added, 14:56, 20 August 2013
See Also
This article explain how to use the data stored within [[SmartSimple]] to determine whether or not a Check Box on an MS Word Merge document is checked.
:''The same principles can be used for many other advanced controls of MS Word Merge documents based on underlying [[SmartSimple]] data.''
==General Procedure==The [[Custom Field Type: Special - MS Word Merge|MS Word Merge Custom Field]] allows you to merge text stored within [[SmartSimple]] into an MS Word document. You cannot merge information directly into a '''Check Box Form Field''' on the MS Word document to make it checked or unchecked.
You cannot merge information directly into a '''Check Box Form Field''' on the MS Word document to make it checked or unchecked. Instead it can be done as follows:
* Create a source ''Text Form Field'' on the MS Word document to store the value that determines whether or not the Check Box should be checked.
* Create the target ''Check Box Form Field'' on the MS Word document
* Create a VB Script that runs automatically when the document opens and does the following:
::* Reads the value in the source Text Form Field and changes the value of the ''Check Box Form Field'' to '''True''' (which will make it checked), if the source value dictates that it should be checked.
::* Deletes the source ''Text Form Field''
Note: these instructions are for MS Word 2003. If you are using ==Example==The following example demonstrates how to check a different version check box on the steps may vary. Please consult MS Word Help for assistancedocument if the source field within [[SmartSimple]] has "CheckMe" as the stored value.
''Note: these instructions are for MS Word 2003. If you are using a different version the steps may vary. Please consult MS Word Help for assistance.''
Create ===MS Word Template===On the MS Word Template document create a ''Text Form Field, then double''. Double-click on it the field and enter a the name '''source''' in the “Bookmark” field.: ''The '''source''' field is where the merge data will be stored. When the MS Word Merge document is opened, a macro will use this value in this field to determine whether or not the associated checkbox should be checked. The field will then be deleted by the macro.''
Next create the ''Check Box Form Field'', double-click on it and enter the name '''target''' in the “Bookmark” field. Be sure that you have created a “Check Box Form Field”, not just a Check Box
The field (named sourcefield in this example) is where the merge data is stored. When the MS Word Merge document is opened, a macro will use this value in this field to determine whether or not the associated checkbox should be checked. The field will then be deleted by the Macro.
  Next create the “Check Box Form Field”, double-click on it and enter a name in the “Bookmark” field. Be sure that you have created a “Check Box Form Field”, not just a Check Box.0  The “check box form field” is named target in this example  Finally open the Tools menu > Macro > VB Visual Basic Editor Double-click on "ThisDocument" on the left-hand pane and then add the following script:
<pre>
Private Sub Document_Open()
</pre>
'''NOTE''': the Document_Open subroutine is NOT executed automatically in MS Word 2002 and earlier. If using earlier versions of Word replace the line::''Private Sub Document_Open()''::with:''Sub AutoOpen()'' ===MS Word Merge Custom Field===On the MS Word Merge Custom Field within SmartSimple you should assign the [[Custom Field]] that determines whether or not the check box will be checked to the '''source''' Text Form Field. Do not assign anything to the '''target''' Check Box Form Field. ==Notes==The [[User|user ]] who performs the MS Word Merge must have Macros macros enabled for MS Word or it will not run.
:* Macros can be enabled via the Tools menu > Macros > Security
:* The setting can be set to either Medium or Low. Medium is recommended, which means the user will have to agree to allow the Macro macro to run each time the document is opened.  When you are creating the original MS Word Merge document you will need to disable macros while you work on the document. Otherwise the source “Text Form Fields” will be deleted by the macro each time you open the document. You should only allow the macro to run when you have actually created the document via the MS Word Merge in [[SmartSimple]].  The "On Error GoTo ExitSub" command in the script is very important. Once the document has been opened the first time the macro deletes all the '''source''' Text Form Fields. Any time the document is opened subsequently the macro will try to reference these fields, and since they no longer exist the command will fail and the macro will exit. 
Hint: You may want to exclude the part of the macro that deletes the source fields while you are working on the document. This will allow you to see if the source fields are populating with the information you would expect to see.
Note: when you are creating the original MS Word Merge document you will need to disable Macros while you work on the document. Otherwise the source “Text Form Fields” will be deleted by the Macro each time you open the document. You should only allow the macro to run when you have actually created the document via the MS Word Merge in SmartSimple.==See Also=={{WordMergeLinks}}
[[Category:Custom Fields]]
8,849
edits