有没有办法为Word VBA组合框文本条目的一部分添加粗体样式?



我有一个启用宏的单词模板,其中包含一个用户表单组合框,我需要它插入的一些文本才能在文档上显示为粗体。我尝试只添加 html 元素,例如粗体 html,但它们不起作用。有没有办法在插入文本时设置部分文本的样式?

'Populate standard_response
With standard_response
.AddItem "<b><u>You were not provided written notice of charge.</u></b> You signed for and received a copy of the offense report detailing the charge against you on 00/00/00.  You also verbally acknowledged during your disciplinary hearing on 00/00/00 that you received a copy of the offense report"
.AddItem "You were not provided at least 24 hours to prepare before hearing.  You received a copy of the offense report detailing the charge against you on 00/00/00.  Your disciplinary hearing was conducted on 00/00/00, therefore, you had at least twenty-four hours to prepare for the hearing.   "
.AddItem "You were not permitted the opportunity to present relevant witness/es or to submit relevant written witness statements.  During the active phase of the investigation you did not wish to call any witnesses as verified by your signature on the 'Disciplinary Coordinator's Report' on 7/19/19.  You were also provided with the opportunity to present relevant written witness statements at your disciplinary hearing but did not do so."
.AddItem "There was no written statement of evidence utilized for a determination of guilt.  Section III of the 'Disciplinary Hearing Report' cites a written statement of evidence relied on for the finding of guilt that identifies the offending behavior and is compliant with Section VII.D.2. of OP-060125, 'Offender Disciplinary Procedures.' "
End With

可以运行一个宏,该宏会根据所使用的下拉选项突出显示部分文本。但更简单的方法包括 1 - 将其保存为模板中的自动图文集/构建块,然后使用下拉选项插入相关文本块或 2 - 格式化所有选项,将它们标记为隐藏文本,然后仅显示所选响应。说明了所有 3 个场景:

Private Sub CommandButton1_Click()
Dim oTextRange As Range
Set oTextRange = ActiveDocument.Bookmarks("Response").Range
Select Case standard_response.value
Case "Item 1"
With oTextRange
.Text = standard_response.value
.MoveEnd Unit:=wdWord, Count:=30
.Font.Bold = True
End With
Case "Item 2"
ActiveDocument.AttachedTemplate.AutoTextEntries("Response1").Insert Where:=oTextRange, RichText:=True
Case "Item 3"
ActiveDocument.Bookmarks("Response1").Range.Font.Hidden = False
Case Else
End Select
End Sub

相关内容

最新更新