【发布时间】:2021-12-18 22:28:12
【问题描述】:
我有这个文本框的代码。
Dim TextBox15 As Range
ActiveDocument.Variables("bmagicf").Value = Me.TextBox15.Value
Me.TextBox15.Value = Me.TextBox15.Text
With ActiveDocument
.Fields.Update
End With
如何在与下面的代码相同的意义上对其应用样式?
Dim ComboBox9 As Range
Set ComboBox9 = ActiveDocument.Bookmarks("bmagich").Range
ComboBox9.Text = Me.ComboBox9.Value
If Me.ComboBox9.Value = "No" Then
ComboBox9.Text = "Appendices"
ComboBox9.Style = ActiveDocument.Styles("Style 22")
End If
我尝试了下面的代码,但没有运气:
Dim TextBox15 As Range
ActiveDocument.Variables("bmagicf").Value = Me.TextBox15.Value
Me.TextBox15.Value = Me.TextBox15.Text
Textbox15.Style = ActiveDocument.Styles("Style 22")
With ActiveDocument
.Fields.Update
End With
【问题讨论】:
-
你不能 - 大多数用户窗体控件甚至没有样式属性。如果是这样(如组合框),您肯定必须设置除 word 文档中定义的样式之外的其他值 - 请参阅:docs.microsoft.com/de-de/office/vba/language/reference/…
标签: vba ms-word combobox textbox userform