Results 1 to 4 of 4

Error 91 when counting and adding commandButton

Threaded View

selector Error 91 when counting and... 04-18-2014, 04:48 AM
LJMetzger Re: Error 91 when counting... 04-18-2014, 09:18 AM
selector Re: Error 91 when counting... 04-20-2014, 04:45 AM
LJMetzger Re: Error 91 when counting... 04-20-2014, 10:24 AM
  1. #1
    Registered User
    Join Date
    04-18-2014
    Location
    Brno
    MS-Off Ver
    Excel 2003
    Posts
    5

    Error 91 when counting and adding commandButton

    Hello,
    i have Userform1 with a few CommandButtons. When i run my VBA code, it return Error 91 - object variable or with block variable not set

    What would i like to do:
    1. I would like to count number of controls on Userform1
    2. I would like to do something with CommandButton1 whitch is placed on Userform1 (change Caption, position ...)

    Please tell me why the Error 91 occurs in this VBA code and how to repair it?

    Dim Button As CommandButton
    
    Debug.Print UserForm1.Controls.Count
    Set Button = ThisWorkbook.VBProject.VBComponents("UserForm1").Designer("CommandButton1") - here is error 91 object variable or with block variable not set
    
    With Button
        .Caption = "New button"
        .Width = 72
        .Height = 24
        .Left = 12
        .Top = 58
    End With
    Thanks for reply
    Last edited by selector; 04-18-2014 at 06:01 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. neede help for creating commandbutton during runtime error
    By aaronkoh in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-03-2013, 09:41 AM
  2. Commandbutton in userform to execute code based on a previous commandbutton choice?
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2012, 03:28 PM
  3. Commandbutton Error When Cancelled
    By Bluewhistler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2010, 04:29 AM
  4. VBA code for adding a commandbutton
    By ben_sumner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2007, 04:06 AM
  5. Adding commandbutton to sheet
    By ckoch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-01-2006, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1