如何使用 vba 代码更改 'Building Block Gallery Content Control' 下拉选择
How to change a 'Building Block Gallery Content Control' drop down selection using vba code
我正在写一个提案,其中用户可以 select 从构建块列表中选择所需的时间表长度,这样他们就不必输入整个段落。
Building Block 选项屏幕截图
有没有一种方法可以更改使用 vba 代码 select 编辑的选项?
到目前为止,这是我在用户窗体中使用组合框尝试过的方法:
Option Explicit
Private Sub CommandButton1_Click()
If ComboBox1.Value = "Based on when drawings can be approved" Then
Application.Templates( _
"U:\Documents Estimating Rotation\Repair Template\Repair Proposal
Template Rev1.dotm" _
).BuildingBlockEntries("Option 2").Insert Where:=Selection.Range, _
RichText:=True
End If
End Sub
Private Sub UserForm_Activate()
'Schedule Options
Me.ComboBox1.Clear
Me.ComboBox1.AddItem "Based on when drawings can be approved"
End Sub
有没有办法将 "Selection.Range" 更改为 select 所需的 'building block gallery content control' 下拉列表?目前所有的代码都是在我的光标位置插入我存储在 'Option 2' 中的文本。
如果需要进一步说明,请告诉我。
不,select Building Block 内容控件中的条目没有规定。您所能做的就是将所需的构建块条目插入到内容控件中。这不一定是 Selection.Range
,它可以是内容控件的 Range
。内容控件不关心插入的内容是否来自列表 - 内容控件将接受任何内容。
假设这是文档中的第一个内容控件,例如:
Dim cc As Word.ContentControl
Dim tmpl As Word.Template
Set cc = ActiveDocument.Contentcontrols(1)
Set tmpl = Templates("U:\Documents Estimating Rotation\Repair Template\Repair Proposal Template Rev1.dotm")
tmpl.BuildingBlockEntries("Option 2").Insert cc.Range, True
我正在写一个提案,其中用户可以 select 从构建块列表中选择所需的时间表长度,这样他们就不必输入整个段落。
Building Block 选项屏幕截图
有没有一种方法可以更改使用 vba 代码 select 编辑的选项?
到目前为止,这是我在用户窗体中使用组合框尝试过的方法:
Option Explicit
Private Sub CommandButton1_Click()
If ComboBox1.Value = "Based on when drawings can be approved" Then
Application.Templates( _
"U:\Documents Estimating Rotation\Repair Template\Repair Proposal
Template Rev1.dotm" _
).BuildingBlockEntries("Option 2").Insert Where:=Selection.Range, _
RichText:=True
End If
End Sub
Private Sub UserForm_Activate()
'Schedule Options
Me.ComboBox1.Clear
Me.ComboBox1.AddItem "Based on when drawings can be approved"
End Sub
有没有办法将 "Selection.Range" 更改为 select 所需的 'building block gallery content control' 下拉列表?目前所有的代码都是在我的光标位置插入我存储在 'Option 2' 中的文本。
如果需要进一步说明,请告诉我。
不,select Building Block 内容控件中的条目没有规定。您所能做的就是将所需的构建块条目插入到内容控件中。这不一定是 Selection.Range
,它可以是内容控件的 Range
。内容控件不关心插入的内容是否来自列表 - 内容控件将接受任何内容。
假设这是文档中的第一个内容控件,例如:
Dim cc As Word.ContentControl
Dim tmpl As Word.Template
Set cc = ActiveDocument.Contentcontrols(1)
Set tmpl = Templates("U:\Documents Estimating Rotation\Repair Template\Repair Proposal Template Rev1.dotm")
tmpl.BuildingBlockEntries("Option 2").Insert cc.Range, True