Changes

Jump to: navigation, search

Including Check Boxes on an MS Word Merge Document

305 bytes removed, 16:13, 22 June 2009
no edit summary
<pre>
Private Sub Document_Open()
 
'--- Exit if an error is encountered
On Error GoTo ExitSub
'--- define variables
Dim sourcefield source As Bookmark Set sourcefield source = ActiveDocument.Bookmarks("sourcefield source")
Dim target As CheckBox
Set target = ActiveDocument.FormFields("target").CheckBox
'--- check the source text and check tick the associated target checkbox if appropriate If (sourcefieldsource.Range.Text = "CheckMe") Then target.Value = True '--- Delete the source bookmark, including the Text Form Fieldfield sourcefieldsource.Range.Delete  '--- Delete this Macro Set vbCom = Application.VBE.ActiveVBProject.VBComponents vbCom.Remove VBComponent:=vbCom.Item("Document_Open")
ExitSub:End Sub
</pre>
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.
You will have to go to Tools>Macro>Security - Trusted Publishers and check Trust access to Visual Basic Editor (or Visual Basic Project) before running the code. Change "Module1" to suit.
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