K
Ken Davis
I have a userform with 6 text boxes. I use a single bookmark to insert the
information into the active document. I'd like to be able to format (bold)
one of the entries as it is inserted in the document.
I've tried tbNAME.font.bold=true and it accepts the statement but it has
no effect on the output. I just don't have the familiarity with OOP and with
Word's internals to know how to proceed. Any light you could shed would be
appreciated.
Thanks in advance! --Ken Davis
VB code is as follows:
Private Sub CommandButton1_Click()
With ActiveDocument
For varCounter1 = 1 To 12 ' varCounter1 increments the inserted text to
cycle through each cell
' Set increment for the number of fields
(bookmarks) in the main document
'VarCellNumber passes a string to append to "bkCELL" which is the base
mnemonic for the cell bookmarks
'this assumes fewer than 20 cells
If varCounter1 < 10 Then varCellNumber = Chr(48 + varCounter1)
If varCounter1 > 9 Then varCellNumber = "1" + Chr(48 + (varCounter1 - 10))
'Actually inserts UserForm2 text into fields. Note that fields are
inserted in reverse order (like pushing onto a stack)
'If statements ignore and/or properly format lines with blank entries
If (tbFACEBOOK) <> "" Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbFACEBOOK)
If (tbMYSPACE) <> "" Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbMYSPACE)
If (tbIM <> "") Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbIM)
If (tbPHONE <> "") And (tbEMAIL <> "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore (tbEMAIL)
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbPHONE) + Chr(9)
ElseIf (tbPHONE <> "") And (tbEMAIL = "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbPHONE)
ElseIf (tbEMAIL <> "") And (tbPHONE = "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbEMAIL)
End If
If (tbNAME <> "") Then
tbNAME.Font.Bold = True
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore (tbNAME)
'Chr(10) + (tbNAME)
End If
Next varCounter1
End With
UserForm2.Hide
End Sub
information into the active document. I'd like to be able to format (bold)
one of the entries as it is inserted in the document.
I've tried tbNAME.font.bold=true and it accepts the statement but it has
no effect on the output. I just don't have the familiarity with OOP and with
Word's internals to know how to proceed. Any light you could shed would be
appreciated.
Thanks in advance! --Ken Davis
VB code is as follows:
Private Sub CommandButton1_Click()
With ActiveDocument
For varCounter1 = 1 To 12 ' varCounter1 increments the inserted text to
cycle through each cell
' Set increment for the number of fields
(bookmarks) in the main document
'VarCellNumber passes a string to append to "bkCELL" which is the base
mnemonic for the cell bookmarks
'this assumes fewer than 20 cells
If varCounter1 < 10 Then varCellNumber = Chr(48 + varCounter1)
If varCounter1 > 9 Then varCellNumber = "1" + Chr(48 + (varCounter1 - 10))
'Actually inserts UserForm2 text into fields. Note that fields are
inserted in reverse order (like pushing onto a stack)
'If statements ignore and/or properly format lines with blank entries
If (tbFACEBOOK) <> "" Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbFACEBOOK)
If (tbMYSPACE) <> "" Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbMYSPACE)
If (tbIM <> "") Then .Bookmarks("bkCELL" +
varCellNumber).Range.InsertBefore Chr(10) + (tbIM)
If (tbPHONE <> "") And (tbEMAIL <> "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore (tbEMAIL)
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbPHONE) + Chr(9)
ElseIf (tbPHONE <> "") And (tbEMAIL = "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbPHONE)
ElseIf (tbEMAIL <> "") And (tbPHONE = "") Then
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore Chr(10) +
(tbEMAIL)
End If
If (tbNAME <> "") Then
tbNAME.Font.Bold = True
.Bookmarks("bkCELL" + varCellNumber).Range.InsertBefore (tbNAME)
'Chr(10) + (tbNAME)
End If
Next varCounter1
End With
UserForm2.Hide
End Sub