+ Reply to Thread
Results 1 to 15 of 15

At least one checkbox must be checked - "OLEObjects error"

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    At least one checkbox must be checked - "OLEObjects error"

    Dear friends,

    From this very forum I vicariously acquired the following vba which could ensure that at least one checkbox had been checked in a range. For the sake of simplicity, I am trialing this in a new excel sheet(2007) with just 5 check-boxes - "check box 1", "check box 2", etc.

    Please Login or Register  to view this content.
    The error I am getting is as follows: Method oleobjects of object _worksheet failed

    The debugger signals that the line If .OLEObjects("Checkbox" & i).Object.Value = "True" Then is the problem.
    So it seems to me that this line is not properly referencing my boxes .

    Could anybody please advise how I should adapt the code to make it work? Additionally, what does oleobject mean?



    N.B, seeing as the code was for a private macro and i didn't want that, I also changed the first line to
    Please Login or Register  to view this content.
    Hopefully this hasn't caused any issues.
    Last edited by henryBukowski; 08-20-2013 at 01:39 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    I suspect you have used Forms controls rather than ActiveX ones, in which case you can refer to the Checkboxes collection instead:
    Please Login or Register  to view this content.
    If you have in fact used Activex, then the names are incorrect in your code.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: At least one checkbox must be checked - "OLEObjects error"

    Hi,

    First check that the exact spelling of the Check Boxes. i.e. are they "Checkbox1", "Check Box 1", etc and make sure your code uses the correct spelling with any embedded spaces.

    I suspect you are using the Forms Control Check Box object, and in which case you should use

    Please Login or Register  to view this content.
    Your code would have worked had you used the Activex Check Box control. These Activex controls seem more robust so unless you have reasons otherwise I'd stick to those.

    An oleobject is simply any external object (like an Excel control), picture image, Word document, Excel spreadsheet, etc..
    Last edited by Richard Buttrey; 08-19-2013 at 07:31 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    Quote Originally Posted by Richard Buttrey View Post
    These Activex controls seem more robust so unless you have reasons otherwise I'd stick to those.
    I couldn't disagree more.

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: At least one checkbox must be checked - "OLEObjects error"

    Thanks guys for the replies.

    So first thingsfirst, I used Form control checkboxes. My rationale was that i was finding it easier to link to a cell with these, because with activeX boxes, I had to go to: Right click on box, go Properites: and then add a reference under 'Linked cell'.

    My checkboxes have the following format "Check Box 1" - So there's a gap between each word and number.

    So, romperstomper: when adding your code instead of mine, the error changes in accordance. That is, the error now reads:

    method checkboxes of object _worksheet failed

    And Richard:

    With the code you suggest, my error has changed to "The Item with the specified name wasn't found. "

    I have tried the following variations of the 'name' but to no avail thus far:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    It appears that I might be getting closer, so I'd really appreciate your continued help, both

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: At least one checkbox must be checked - "OLEObjects error"

    @Romperstomper

    ... all in the eye of the beholder

    Perhaps 'flexible' would have been a better adjective...

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: At least one checkbox must be checked - "OLEObjects error"

    Hi,

    Exactly what does your CheckBox say in the Name box when you select it?
    By default it presumably says "Check Box 1"
    I don't think the case matters but try Box rather than box.

    Upload your workbook if it's still a problem.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    Quote Originally Posted by Richard Buttrey View Post
    Perhaps 'flexible' would have been a better adjective...
    or "unstable"

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: At least one checkbox must be checked - "OLEObjects error"

    Hiya,

    So "Check Box 1" is an example of what appears in the name bar.

    I was trying this out in a blank workbook which I have uploaded - thanks.

    i also pasted the code below in case the macro has not transferred with the file.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    This code:
    Please Login or Register  to view this content.
    works for me with your sample workbook.

  11. #11
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: At least one checkbox must be checked - "OLEObjects error"

    Quote Originally Posted by romperstomper View Post
    This code:
    Please Login or Register  to view this content.
    works for me with your sample workbook.
    Wowzer...!

    That's really weird - I had to start an entirely new document, name the sub something else and insert a fresh module, then it worked as you said...however, it wasn't working in my sample.

    While I'm at it, would you happen to know how I could add another 'clause' to the code so that one of this range, 1-5 had to be checked, and also one of a second range had to be checked?

    So if it was a form you were filling in:

    Question 1: Options A B C
    Question 2: Options A B C

    So that you've only finished the form if you've chosen one option for question 1, and also 1 option for question 2.

    Where would I add a second clause?

    Thanks so much, by the way.

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: At least one checkbox must be checked - "OLEObjects error"

    @romperstomper

    Moi aussi!

    @ Henry

    There was no code in the workbook attached, but the code that you show in the post has

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    yet your checkboxes have the default names of "Check Box 1" etc. i.e with a space either side of 'Box.' As mentioned you'll need to ensure your code says

    Please Login or Register  to view this content.
    or romper stompers equivalent
    Please Login or Register  to view this content.

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    If you only have two questions, then you could just add another loop:
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: At least one checkbox must be checked - "OLEObjects error"

    Quote Originally Posted by romperstomper View Post
    If you only have two questions, then you could just add another loop:
    Please Login or Register  to view this content.
    Perfect - If both are missing it seems to only alert for the first of the two that's missing - but that's absolutely fine. Hooray!!!

    I'm interested though, the way you said that if I have only two questions - are you suggesting that if I have more than 2 questions I should do it a different way? I ask because, whilst in this section of my form there's only 2 questions, another section has like 5.

    This has been really helpful :D

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: At least one checkbox must be checked - "OLEObjects error"

    For multiple questions I would use a separate validation function, such as this:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 01-08-2013, 10:36 AM
  2. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  3. Remove "TRUE" "FALSE" words from a linked checkbox
    By MDCK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2008, 03:26 AM
  4. Replies: 0
    Last Post: 06-08-2006, 12:55 PM
  5. What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 PM

Tags for this Thread

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