Changes

Jump to: navigation, search

Including Check Boxes on an MS Word Merge Document

2,500 bytes added, 15:29, 22 June 2009
no edit summary

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 [[Custom Field Type: 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.


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 a Text Form Field, then double-click on it and enter a name in the “Bookmark” field.



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 Editor and add the following script:

Private Sub Document_Open()

'--- define variables
Dim sourcefield As Bookmark
Set sourcefield = ActiveDocument.Bookmarks("sourcefield ")

Dim target As CheckBox
Set target = ActiveDocument.FormFields("target").CheckBox

'--- check the source text and check the associated checkbox if appropriate
If (sourcefield.Range.Text = "CheckMe") Then target.Value = True

'--- Delete the source bookmark, including the Text Form Field
sourcefield.Range.Delete

End Sub


The user who performs the MS Word Merge must have 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 to run each time the document is opened.

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.
0
edits

Navigation menu