|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我对一个Master绑定了一个ComboBox,想触发Document_ShapeAdded()时候,自动对该shape中的ComboBox自动赋值(已经从Excel文件中读出了:ComboBox2.AddItem myrange.Text)。
附代码:
Private Sub Document_ShapeAdded(ByVal Shape As IVShape) Dim wb As Object, rng As Object Dim strFileName As String Dim i, shape_num As Integer Dim BoxName As String Debug.Print "shape added " '获取excel文件名 strFileName = ThisDocument.Path & "book1.xls" '获取excel对象 Set wb = GetObject(strFileName) '获取当前页面所有shape的数目 shape_num = ActivePage.Shapes.Count Debug.Print "total " & shape_num & " shapes!" For i = 2 To shape_num
BoxName = "ComboBox" & i ' If BoxName.Exit Then ' 加载该工作薄第一工作表"A1:A10"的值到列表框中 For Each rng In wb.worksheets(1).Range("A2:A10") If (Trim(rng.Text) <> "") Then '!!如何可以对所有的combobox进行下列操作??? ComboBox2.AddItem rng.Text Debug.Print BoxName & " dataed successful !" End If Next ' End If Next i ' 关闭 'wb.Close 'Set wb = Nothing End Sub
----思路不太清晰,请大家指点,欢迎交流。。he_jian@octiga.com |
|