English 中文(简体)
使用Excel的VBBA表格控制程序
原标题:Accessing Event Procedures of Form Controls with VBA in Excel

是否有办法界定窗体控制的事件程序,如对 AmericanX 对象的窗体控制?

我有一个用户目前添加/ removes ApactX 命令按钮的 GUI 界面, 由用户添加/ removes ActiveX 命令按钮, 但它运行到 < a href=> http://msdn. microsoft.com/ en- us/ library/ aa264506%28v=vs. 60%29. aspx" rel= "nofollow" > "Error 91 , 试图将一个项目添加到一个全球收藏中, 添加每个按钮。 我最好的猜测是 < a href=> http://www. pcreview.co.uk/ forums/ diralally- addadadding- activactex- control- via- vba- kills- global- vba-heap- t3763287.html" rel= " rel= " no fol fol " > > > this most a production a/ a/ a/ a/ a a/ a pactivX conct press press press pract press press press press press press press

最佳回答

如果您只想添加按钮和抓取单击, 您可以为它们指定一个共同的宏, 并切换根据按钮名称( 在创建按钮时您将设置该按钮, 并且可以通过 Application.Caller 访问该按钮) 所要采取的行动 。

Sub AddButtons()

    With ActiveSheet.Buttons.Add(100, 100, 50, 50)
        .Name = "button1"
        .OnAction = "ClickHandler"
    End With
    With ActiveSheet.Buttons.Add(200, 100, 50, 50)
        .Name = "button2"
        .OnAction = "ClickHandler"
    End With


End Sub

Sub ClickHandler()
    Dim bName As String

    bName = Application.Caller
    Select Case bName
        Case "button1": MsgBox "Clicked First button"
        Case "button2": AnotherSub 
    End Select

End Sub
问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签