+ Reply to Thread
Results 1 to 16 of 16

Button visibility and colour

  1. #1
    Registered User
    Join Date
    08-27-2007
    Posts
    48

    Button visibility and colour

    Hi,
    I would like to make a command button invisible, and to change its colour. I have Googled but cannot find out how to do this - button1.visible=false returns an "Object required" error message - any ideas?
    Cheers,
    Lotte

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Assuming that the commandbutton name is button1 then try

    Please Login or Register  to view this content.

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    Hi Rylo,
    Thanks for the reply. The code you suggested returns the following error:
    "Object doesn't support this property or method". Hmm. I'm using MS VB 6.3. Any ideas?
    Lotte

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    What is the name of the button, and are you on the sheet with the button when you run the code?


    rylo

  5. #5
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    Hi,
    Yes, the active sheet contains the button. The code is:


    Please Login or Register  to view this content.

    Lotte
    Last edited by VBA Noob; 09-24-2007 at 04:27 AM.

  6. #6
    Registered User
    Join Date
    09-10-2007
    Posts
    4
    Well, you could try from the drawing toolbar, just create a rectangle and change the line properties to "no line", then asign a macro to it. Then just change the color of it as the same color of your background to make it appear invisible.

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Can you attach a copy of the spreadsheet, removing any sensitive data, and retain any relevant code.

    rylo

  8. #8
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    Hi rylo,
    It seems I cannot attach excel sheets to posts to this forum...?
    Lotte

  9. #9
    Forum Contributor
    Join Date
    03-23-2007
    Location
    Essex, UK
    MS-Off Ver
    MS365 V2308
    Posts
    279
    You have 2 ways of attachment..
    either zip the file (right click it and choose zip ) then upload this or add the extension .txt

  10. #10
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    Thanks. See attached. The offending command is in the StartNewQaSession_Click() sub.
    Lotte
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    The button with the caption Start New QA Session is acutally Button 17. So the line

    Please Login or Register  to view this content.
    should get you there.


    rylo

  12. #12
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    rylo,
    That worked - thanks very much!
    Lotte

  13. #13
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    How can I display the name of the control? I've been creating a macro and looking at the name suggested by VBA - there must be a better way...?
    Lotte

  14. #14
    Registered User
    Join Date
    09-25-2007
    Location
    Singapore
    Posts
    15
    On the worksheet itself, double-click on the command button and it will show you the codes right.(make sure u under the design mode)

    Right after that, u click on 'Properties Window'. And there under the properties for command button, under caption, you rename the name of the control aites!

    that's all.

    if its not clear, do tag back.
    ~~~~~~~~~~
    lily

  15. #15
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    As you have used the command button from the forms menu, not the control toolbox menu, things are a bit more complicated.

    If you have the spreadsheet open, and the VBE open and show the immediate window.

    Hold down the control key, then select the button.

    Then go to the immeditate window and type in the command
    ?activesheet.shapes.count

    Then you can go through the shapes and select them until you manage to select the shape you want to examine
    activesheet.shapes(1).select (increase the number)

    Once you have determined the relevant shape number you can type in
    ?activesheet.shapes(i).name (where i is the relevant shape number).

    That will give you the shape name.

    Things would be much easier if you selected the button from the control toolbox. Can put code directly into the button event, and you can use the properties as well.

    rylo

  16. #16
    Registered User
    Join Date
    08-27-2007
    Posts
    48
    rylo,
    Thanks very much.
    Lotte

+ 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