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

詹姆斯·约翰逊

我有一个启用宏的 word 模板和一个用户表单组合框,我需要它插入的一些文本在文档上显示为粗体。我尝试只添加 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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

VBA Word如何将数组的一部分传递给子例程?

有没有办法将文本添加到带有反应的消息中

有没有办法像c#这样在Excel的VBA中注释行的一部分

有没有办法使用组合框数据 (VBA) 更改 Word 文档的文件名和电子邮件主题?

VBA Word 搜索一行并替换它的一部分

在ms word中用vba加粗段落的一部分

在 Word VBA 中将文本的一部分设为超链接

Excel-将大于或小于符号视为文本条件的一部分

有没有办法将一个图标添加到 MailChimp 嵌入表单的“提交”按钮?

删除 Word VBA 中的最后一部分,而不会覆盖上一个标题

有没有办法到样式添加到一个MVC视图的机身采用布局页面

如何用 MS Word 粗体格式化图形标题的一部分,而另一部分是常规格式?

有没有办法在 Microsoft Word 中使用 VBA 搜索字符串并突出显示相邻单词

有没有办法在侧边栏中添加主导航的一部分?

有没有办法在fortran中读取文件的一部分?

有没有办法隔离字符串的一部分?

有没有办法将 javascript 变量用作 PHP SQL 页面的一部分?

如何使用 VBA 截断带有通配符的单词的一部分

有没有办法更改添加到现有项目目录的PHP项目的文档根目录?

Excel VBA将项目添加到组合框中,没有重复的项目

有没有办法使用postgresql将具有不同ID的同一行多次添加到表中?

有没有一种方法可以将背景添加到Word页面但不保存在.docx文件中?

使用VBA将Excel工作表(的一部分)导出到CSV的范围

有没有办法将每个值添加到 JS for 循环中的第一个值?

有没有办法像使用管理控制台一样使用CLI将安全组添加到EC2实例?

有没有一种方法可以将属性添加到函数中作为函数定义的一部分?

将 onClick 添加到 RecyclerView 项目的一部分

有没有办法只读取输入文件的一行的一部分?

Word VBA仅格式化查找替换字符串的一部分(格式化以字符串开头的段落)