Results 1 to 7 of 7

Thread: checkboxes to text in MS word

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    4

    checkboxes to text in MS word

    Helloo VB gurus,
    I work in a doctors office and am hoping for someone can lend some help. I have created a simple template form in MS word with many checkboxes and several textboxes. My goal is to link the checkboxes to another word document, such that the new document will return specific text values for each checkbox depending on whether their value is "true" or "false." I am also looking to return the actual text box values in the word form to the new document. I have experience using mail merge with excel/word, but unfortunately am new to VB. Is there a way to go about this without using excel or other database program? Thanks so much for your help

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: checkboxes to text in MS word

    you can read the checked value of each checkbox, but
    are you using forms checkboxes or controls checkboxes as the code would be different for each, which menu do you use to add the checkboxes?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: checkboxes to text in MS word

    thanks for the quick reply, i... think the answer to your question is that i'm using "active-x control" checkboxes... does that make sense? thanks again

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: checkboxes to text in MS word

    to add checkboxes, i use MS word 2007>developer tab>controls>legacy tools>activeX control checkbox

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: checkboxes to text in MS word

    as i don't have 2007 i just guess these are same as controls checkboxes /textboxes

    if so you can address them as members of the inlineshapes collection, that way you can loop through them
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: checkboxes to text in MS word

    ok, so could you tell me how to address them as members of the inlineshapes collection and loop through them, or where else to look to get that information? Thanks for your patience, I don't have much programming experience

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: checkboxes to text in MS word

    i guess if you have bookmarks in the destination document with the same names as the text or checkboxes

    for textboxes something like
    vb Code:
    1. for each ctrl in documents("sourcedoc").inlineshapes
    2.   with ctrl.oleformat.object
    3.     select case typename(ctrl.oleformat.object)
    4.       case "TextBox":    activedocument.bookmarks(.name).range.text = .value
    5.       case "CheckBox"  
    6.         if .value then
    7.             activedocument.bookmarks(.name).range.text = somevalue ' based on checkbox name and checked
    8.            else
    9.              activedocument.bookmarks(.name).range.text = someothervalue  ' based on checkbox name and unchecked
    10.         end if
    11.      end select
    12.   end with
    13. next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width