![]() |
|
#11
|
|||
|
|||
|
Like someone given a fine 35mm camera who doesn’t know what a film advance does and therefore can’t make the machine work, I return yet again after another couple of hours of trying to make your undoubtedly perfect your code work, stumbling around without being able to find answers to my searches on VBA syntax. Perhaps I just named things in a bad way that increases my confusion. So, if I may, here is a new attempt with the same example, using a naming system that could work for my project as it expands.
As before, all docs are on my desktop in a folder called Form. I have named the target document Target, the source document Source1, and the two bookmarks in Source1 -- standing, respectively, for Source1 Bookmark1 True and False -- are S1B1T and S1B1F, the latter an empty paragraph to correspond to an unchecked check box. You said “a macro” is needed for checkboxes, so I assume you refer to Graham Mayor’s at the site I linked. Check1 presumably refers to check box 1 in Target. His macro appears to automatically create a bookmark called Check1, which baffles me, because it seems this would be what I create as the bookmark enclosing the includetext field on page two. I have tried to adapt his example to my situation. It seems to me that the sTrue and sFalse lines need to include the names of the two bookmarks (he uses two separate documents), but I don’t know how to properly insert them (somewhere within the triple quotation marks?). I can only guess that rText (return text?) refers to my includetext field, but I’m lost with the code. Code:
Sub OnExitCB1()
Dim rText As Range
Dim sTrue As String
Dim sFalse As String
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
sTrue = """C:\\Desktop\\Form\\Source1.docx"""
sFalse = """C:\\Desktop\\Form\\Source1.docx"""
Set rText = ActiveDocument.Bookmarks("Check1Result").Range
If oFld("Check1").CheckBox.Value = True Then
rText , wdFieldIncludeText, sTrue, False
rText.MoveEnd wdCharacter, 1
Else
rText.Fields.Add rText, wdFieldIncludeText, sFalse, False
rText.MoveEnd wdCharacter, 1
End If
With ActiveDocument
.Bookmarks.Add "Check1Result", rText
.Fields.Update
End With
End Sub
Code:
{INCLUDETEXT "{FILENAME \p }/../Text1.docx" "Check1{IF{REF Check1}= TRUE 2 1}"}
I would think that, for starters, it should be, in my case, Code:
{INCLUDETEXT "{FILENAME \p }/../Source1.docx" "Field1{IF{REF Check1}= TRUE 2 1}"}
In case I'm proceeding wrong: After creating Source, my procedure in Target has been to create the include text field and get that to work (at least, bringing in the entirety of Source1). Then I try to modify the field, successively including the additional sub-fields and typed text. This is where I start getting "bookmark not defined" errors. With Mayor's macro already installed, then I try inserting the legacy checkbox, following Mayor's settings. I am determined to make this work, and repeat my thanks for all your help. |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Divide Word Form into two separate documents
|
mortcr | Word VBA | 1 | 10-22-2013 02:02 PM |
Best options for setting tab order in a form
|
DBrooks | Word | 1 | 02-16-2013 01:32 PM |
Form field selection allows entry into form text box
|
David C | Word | 1 | 10-24-2012 04:53 AM |
problems saving Word documents in .pdf form
|
kellyjb27 | Word | 1 | 05-26-2012 11:08 AM |
Form Fields - Create blank form text field with if statement?
|
LAssist2011 | Word | 5 | 12-14-2011 03:02 PM |