Unable to Execute Macro With ActiveX Controls (Excel VBA)

戏子无情 提交于 2019-12-11 07:17:08

问题


Problem: Users on different machines unable to execute VBA macro that works perfectly on my machine and the machines of others.

Having issues with ActiveX form controls in MS Excel 2010 v.14.0.7015.1000 (32-bit). Using ActiveX Button and Text box I wrote VBA code that populates the text box when the button is clicked.

The code executes perfectly on my machine and has worked on other machines. I am having issues with other users being able to click the button. I told the user having trouble to try to run the Macro with the Alt+F8 keyboard command, but the user got an "object required" error.

Have hit a wall and I am looking for anything that might help.

Also tried this forum related to a MS update to no avail: Microsoft Excel ActiveX Controls Disabled?

Thanks in advance!

Attached is the code if helpful:

Public Sub CommandButton1_Click()


'Clear Working tab spreadsheet

    Worksheets("Sheet3").Range("A:AF").ClearContents

'-----------------

'Filter One Doc to correct process and requirement

'    Process

    Worksheets("One Doc Copy").Range("A2:AF12073").AutoFilter _
    Field:=4, _
    Criteria1:=Worksheets("MASTER TAB").Cells(2, ActiveCell.Column), _
    VisibleDropDown:=False

'    Requirement

    Worksheets("One Doc Copy").Range("A2:AF12073").AutoFilter _
    Field:=12, _
    Criteria1:=Worksheets("MASTER TAB").Cells(ActiveCell.Row, 2), _
    VisibleDropDown:=False

'-----------------

'Copy Filtered One Doc Data to Working Tab (Sheet3)

    Worksheets("One Doc Copy").Range("A2:AF12073").SpecialCells(xlCellTypeVisible).Copy _
    Destination:=Worksheets("Sheet3").Range("A3")

'-----------------

'Return the number of results for counter (find safer place for value)

    Dim Counter As Integer
    Counter = Worksheets("MASTER TAB").Range("DX3").Value

'-----------------

'Populate Text Box

Dim process, ctrlTxt As String
process = Worksheets("MASTER TAB").Cells(2, ActiveCell.Column)

If Counter = 0 Then

    TextBox1.Text = "There are no assigned requirements for: " & process

Else

    TextBox1.Text = "Controls for: " & process & vbLf & vbLf _
    & "Requirement #: " & Worksheets("sheet3").Range("L3").Value & vbLf _
    & "Requirement Description: " & Worksheets("sheet3").Range("M3").Value & vbLf _
    & "Total Number of Controls: " & Counter & vbLf _
    & "-----------------" & vbLf & vbLf

    For x = 0 To Counter - 1

        ctrlTxt = ctrlTxt & "(" & x + 1 & ")" & vbLf & vbLf _
                    & "Control Type: " & Worksheets("sheet3").Cells(3 + x, 19) & vbLf & vbLf _
                    & "Control Description: " & vbLf & vbLf & Worksheets("sheet3").Cells(3 + x, 20) & vbLf & vbLf _
                    & "---" & vbLf

    Next

    TextBox1.Text = TextBox1.Text + ctrlTxt

End If

End Sub

来源:https://stackoverflow.com/questions/28746724/unable-to-execute-macro-with-activex-controls-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!