Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IsType of Object (Word 2000)

    In my document automation project I use the tag ID of checkboxes and textboxes to tell my code where to insert the textbox text or which form checkbox to turn on. I take a form and iterate through all the textboxes using

    If TypeOf oThisForm.Controls(i) Is TextBox Then

    to determine if the control is a textbox.

    The problem is that this same line of code does not work if I substitute CheckBox for Textbox even though using the de###### I clearly see the control's type is Checkbox

    I've worked around this by simply making sure all my checkboxes begin with "chk" and then doing an Left on the first 3 characters to see if they = chk but I'm wondering why I can't determine the type on a Checkbox.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IsType of Object (Word 2000)

    Prefix the type by MSForms:

    If TypeOf oThisForm.Controls(i) Is MSForms.CheckBox Then

    This works for other types too (including TextBox). I don't know why the check box requires this syntax, while others don't.

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IsType of Object (Word 2000)

    Thanks... I would never have thought of that. I'll try it out!

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IsType of Object (Word 2000)

    Qualification is needed because there are two kinds of CheckBox, MSForms and Word.

Posting Permissions

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