+ Reply to Thread
Results 1 to 17 of 17

enabling a vba control form button in vba code

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    enabling a vba control form button in vba code

    Hi,

    I am currently building a worksheet which has two VBA Control Form buttons. I have code which activates when the workbook opens which says if cell A18 is blank then enable the first button and disable the second and if it is not blank then disable the first button and enable the second. The code is not in a macro it is the workbook open object

    Currently the code is:

    Please Login or Register  to view this content.
    However when it gets to the line highlighted in red it produces the error "Run-time error '438' Object doesn't support this property or method".

    Is the code I have used wrong? or Do I need a library enabled to use the VBA control form?

    Thanks,

    Jeskit

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enabling a vba control form button in vba code

    Is there three ts in

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: enabling a vba control form button in vba code

    Hi

    Yes I have just misspelled but this code is just a test to see if it would work. Once it does I will change the names.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enabling a vba control form button in vba code

    It won't work if the spelling is incorrect.

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook. Don't upload a picture when you have a workbook question. None of us is inclined to recreate your data. Upload the workbook and manually add an 'after' situation so that we can see what you expect. In addition clearly explain how you get the results..
    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.
    To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'.
    Clicking this button will open a new window for uploading attachments.

    You can upload an attachment either from your computer or from another URL by using the appropriate box on this page.
    Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file.

    To upload a file from another URL, enter the full URL for the file in the second box on this page.
    Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  5. #5
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: enabling a vba control form button in vba code

    Hi

    sorry, the spelling is correct, however when naming the button i just accidentally spelled it wrong

  6. #6
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: enabling a vba control form button in vba code

    Hi,

    thank you for replying

    I ahve tried changed it to buttons and placing it within a with however I now get "Run-time error '1004' Application-defined or Object-defined error"

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: enabling a vba control form button in vba code

    On which line?
    Good luck.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: enabling a vba control form button in vba code

    Please Login or Register  to view this content.
    - check the name of the sheet

    if you mixed up form controls and ActiveX controls:

    Please Login or Register  to view this content.
    Last edited by snb; 02-27-2012 at 08:23 AM.



  9. #9
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: enabling a vba control form button in vba code

    Sorry I forgot to say which line it was erroring on, I have highlighted the line in red

    Please Login or Register  to view this content.

  10. #10
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: enabling a vba control form button in vba code

    Please Login or Register  to view this content.
    is the equivalent of what I posted.
    Last edited by OnErrorGoto0; 02-27-2012 at 08:40 AM.

  11. #11
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: enabling a vba control form button in vba code

    HI I ahve tried your code and I am still getting "Run-time error '1004' Application-defined or Object-defined error"

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: enabling a vba control form button in vba code

    You better post your workbook.

  13. #13
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: enabling a vba control form button in vba code

    I'd ask you to post the workbook but I've just noticed that the buttons don't actually get disabled anyway, even when the code runs, so I would suggest switching to ActiveX buttons and using:
    Please Login or Register  to view this content.

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: enabling a vba control form button in vba code

    @OnError, they do, their appearance just doesn't change as ActiveX controls do

  15. #15
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: enabling a vba control form button in vba code

    Kyle,
    Not in my tests earlier today they don't. Both buttons remained fully functional, even though I stepped through the code to ensure it was running. This was Excel 2010. (Pre SP1 I think as my IT department are slow)

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: enabling a vba control form button in vba code

    Ah right, something may have changed and your IT department are speedy compared to ours, running XP with office 2003

  17. #17
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: enabling a vba control form button in vba code

    To be fair we only got 2010 two weeks ago, so it's no surprise they haven't given us SP1 yet. I'd be happier if they gave me PowerPivot quicker...

+ 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