Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7951009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:26:04+00:00 2026-06-04T02:26:04+00:00

During runtime, the user is able to add any number of ActiveX command buttons

  • 0

During runtime, the user is able to add any number of ActiveX command buttons to Sheet 1. I need to have a reference to these new buttons with VBA, but am not sure how.

I know a logical progression which the button names will exhibit: ex.

(Node#x2)-2=CommandButton#=i

I need to somehow refer to these newly created buttons, I’m thinking is along the lines of this:

Sheet1.Controls("CommandButton" & i).Select

If anyone knows the correct syntax or an alternate method please advise!

UPDATE

Public Sub Node_Button_Duplication()
'
'Comments: Copies and pastes Node 1's button to the appropriate column

' Copy Node 1 button and paste in appropriate location
    ActiveSheet.Shapes("CommandButton1").Select
    Selection.Copy
    Cells(5, 10 + 7 * (NumNodes - 1) - 1).Select
    ActiveSheet.Paste
    Selection.ShapeRange.IncrementLeft 47.25
    Selection.ShapeRange.IncrementTop -13.5


End Sub

Follow-Up

Public Sub Node_Button_Duication()
'
'Comments: Copies and pastes Node 1's button to the appropriate column

Dim shp As Shape

' Copy Node 1 button and paste in appropriate location
    ActiveSheet.Shapes("CommandButton1").Select
    Selection.Copy
    Cells(5, 10 + 7 * (NumNodes - 1) - 1).Select
    ActiveSheet.Paste
    Selection.ShapeRange.IncrementLeft 47.25
    Selection.ShapeRange.IncrementTop -13.5

    Debug.Print Selection.Name

    Set shp = ActiveSheet.Shapes(Selection.Name)

    With shp.OLEFormat.Object.Object
        .Caption = "Test"
        .Left = 15
        .Top = 15
    End With

End Sub

This gives me a Run-time error “438: Object doesn’t support this property or method. I don’t particularly understand

shp.OLEFormat.Object.Object
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:26:05+00:00Added an answer on June 4, 2026 at 2:26 am
    Public Sub Node_Button_Duplication()
        ActiveSheet.Shapes("CommandButton1").Select
        Selection.Copy
        Cells(5, 10 + 7 * (NumNodes - 1) - 1).Select
        ActiveSheet.Paste
        Selection.ShapeRange.IncrementLeft 47.25
        Selection.ShapeRange.IncrementTop -13.5
    
        '~~> This will give you the name
        Debug.Print Selection.Name
    End Sub
    

    FOLLOWUP

    If you know the name of the commandbutton then you can change the properties like this.

    Option Explicit
    
    Sub Sample()
        Dim shp As Shape
    
        '~~> Since you already have the name replace "CommandButton1" by
        '~~> the name that you have
        Set shp = ActiveSheet.Shapes("CommandButton1")
    
        With shp.OLEFormat.Object
            .Object.Caption = "Test"
            .Left = 15
            .Top = 15
        End With
    End Sub
    

    You can also combine the above two like this

    Public Sub Node_Button_Duplication()
        Dim shp As Shape
    
        ActiveSheet.Shapes("CommandButton1").Select
        Selection.Copy
        Cells(5, 10 + 7 * (NumNodes - 1) - 1).Select
        ActiveSheet.Paste
        Selection.ShapeRange.IncrementLeft 47.25
        Selection.ShapeRange.IncrementTop -13.5
    
        '~~> This will give you the name
        Debug.Print Selection.Name
    
        Set shp = ActiveSheet.Shapes(Selection.Name)
    
        With shp.OLEFormat.Object
            .Object.Caption = "Test"
            .Left = 15
            .Top = 15
        End With
    
    End Sub
    

    And if you need to iterate through all the buttons then use this code.

    Sub CommanButtons()
        Dim wks As Worksheet
        Dim OLEObj As OLEObject
    
        '~~> set it as per the relevant sheet
        Set wks = Worksheets("sheet1")
    
        For Each OLEObj In wks.OLEObjects
            If TypeOf OLEObj.Object Is MSForms.CommandButton Then
                Debug.Print OLEObj.Object.Caption
            End If
        Next OLEObj
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSF + Hibernate app. During runtime, i need to change database, to
How do I change any CSS properties during runtime? Suppose I have: #mycss {
Can we change the stage size during runtime? I need to change the size
i am adding more than one link button during runtime but they all have
I have a stackpanel with some usercontrols that are added or removed during runtime.
How do I request Administrator privileges during runtime so the user is given the
In my project i need to switch between databases during runtime. I tried to
I have a user control inside a webpart inside sharepoint that I add some
I need to create a strongly typed dataset during run-time for the user preferred
i have the following code, which fails during runtime... var mock = new Mock<ControllerContext>();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.