+ Reply to Thread
Results 1 to 5 of 5

Custom button enabling/disabling

  1. #1
    Registered User
    Join Date
    03-22-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Custom button enabling/disabling

    Hello,

    I have made a questionnaire style program, which has several custom buttons. When I mean custom, I mean buttons I created from text boxes, which are assigned to a certain macro in my code (in a Module).

    I would like to learn how to disable and enable these buttons in my code.

    I have tried giving my buttons names, e.g. for the start button I have named it startBurron. I know it is using the enabled property but when I try something like:

    Please Login or Register  to view this content.
    I get a variable not defined error. Can someone please explain?

  2. #2
    Registered User
    Join Date
    03-24-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Custom button enabling/disabling

    The short answer is to purely add "Me." in front of the line
    Please Login or Register  to view this content.
    Remember that this line should be in the correct module to work.

  3. #3
    Registered User
    Join Date
    03-22-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Custom button enabling/disabling

    Hi,

    I get a Invalid use of Me keyword error when I put "Me" in front of that statement. All my code is in Module 1 (which is the only module I have). Can I only use "Me" in the code of my 'test' worksheet?

  4. #4
    Registered User
    Join Date
    03-24-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Custom button enabling/disabling

    Sorry, my mistake.
    The problem is that it doesn't know whete to find the startbutton.
    If you use me, it searches for the startbutton in the sheet or userform connected to the module.
    Otherwise you will have to indicate where exactly that button is situated. If it is in sheets1 then:
    sheet1.startbutton.enabled = false
    Hope this helps

  5. #5
    Registered User
    Join Date
    03-22-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Custom button enabling/disabling

    Thanks for the explanation but no luck. It now says Method or data member not found when I enter:

    Please Login or Register  to view this content.
    I also tried "test" which is the name of Sheet1 but I think Sheet1 is correct. I am not sure why the startButton is not being recognized. I have selected it and entered "startButton" in the Name Box of Excel. I have also tried the Insert -> Name -> Define method and entered ="startButton" but no luck.

    One thing I have noted is that I can't see startButton from the available names in the Name Box. Am I doing Something wrong here?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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