Hello, can you help? I'm at the end of what I know how to do. I have a
template that merges itself with data from a Word table stored in another
document (this part works fine). The form collects some info from the user
and has option buttons and check boxes. I can't get these to work. I've
checked the spelling and usage of bookmarks and box/button names and they are
correct. My Combobox1 has a selection of delivery options and so does
Combobox 2. I can get this code to work in other templates that do not
invoke a merge. I'm on Word XP and here's my macro:
The entire macro follows, but the portion that I have here in caps is the
part that doesn't work.
ODOC.BOOKMARKS("BKDELIVERY").RANGE.TEXT = FRMSELECT.COMBOBOX1.TEXT +
FRMSELECT.COMBOBOX2.TEXT
' END IF
IF FRMSELECT.OPTPERS.VALUE = TRUE THEN
ODOC.BOOKMARKS("BKPANDC").RANGE.TEXT = "PERSONAL AND CONFIDENTIAL"
END IF
IF FRMSELECT.OPTATTORNEY.VALUE = TRUE THEN
ODOC.BOOKMARKS("BKPANDC").RANGE.TEXT = "ATTORNEY CLIENT PRIVILEGE"
END IF
Private Sub Document_New()
Dim ComboBox1 As ComboBox
Dim ComboBox2 As ComboBox
Dim oDoc As Document
Dim ofrmSelect As frmSelect
Set ofrmSelect = New frmSelect
Set oDoc = ActiveDocument
Load ofrmSelect
ofrmSelect.MyList.Clear
If ofrmSelect.cmdCancel = True Then ActiveDocument.Close wdDoNotSaveChanges
DoEvents
oDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord
Do
ofrmSelect.MyList.AddItem oDoc.MailMerge.DataSource.DataFields("Name")
nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord
oDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord
Loop Until nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord
ofrmSelect.MyList.ListIndex = -1
ofrmSelect.Show
oDoc.Bookmarks("bkDelivery").Range.Text = frmSelect.ComboBox1.Text +
frmSelect.ComboBox2.Text
' End If
If frmSelect.optPers.Value = True Then
oDoc.Bookmarks("bkPandc").Range.Text = "PERSONAL AND CONFIDENTIAL"
End If
If frmSelect.optAttorney.Value = True Then
oDoc.Bookmarks("bkPandc").Range.Text = "ATTORNEY CLIENT PRIVILEGE"
End If
If ofrmSelect.mReturn Then
nListIndex = ofrmSelect.MyList.ListIndex
Unload ofrmSelect
Set ofrmSelect = Nothing
'Unload ofrmSelect
End If
If nListIndex <> -1 Then
oDoc.MailMerge.DataSource.ActiveRecord = nListIndex + 1
sName = oDoc.MailMerge.DataSource.DataFields("Name")
End If
oDoc.Bookmarks("bkName").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Name")
oDoc.Bookmarks("bkDD").Range.Text =
oDoc.MailMerge.DataSource.DataFields("DD")
oDoc.Bookmarks("bkEMail").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Email")
oDoc.Bookmarks("bkSig").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Sig")
nStart = 1
Do
nNext = InStr(nStart, sAddress, Chr(13), vbBinaryCompare)
nLineCount = nLineCount + 1
nStart = nNext + 1
Loop Until nNext = 0
oDoc.Range.InsertAfter (sAddress & Chr(13))
Selection.MoveUntil Chr(9), wdForward
Selection.Expand wdParagraph
oDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
Set oDoc = Nothing
Selection.GoTo what:=wdGoToBookmark, Name:="bkStop"
End Sub
THANKS FOR ANY SUGGESTIONS
Doug Robbins - Word MVP - 25 Apr 2007 19:57 GMT
For starters, the code in uppercase should be run by means of the click
event of a command button on the form, not as part of the autonew macro.
The loading of the combobox should be in the initialize event of the form.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hello, can you help? I'm at the end of what I know how to do. I have a
> template that merges itself with data from a Word table stored in another
[quoted text clipped - 108 lines]
>
> THANKS FOR ANY SUGGESTIONS