Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exporting text/check boxes to comment string in Word '10

    Hi All,

    I have something I'd like to do in Word '10. I'm trying to take information from several form boxes (Textbox1,2,3 etc), and create a comment with this information inside.

    For instance:

    Box 1: Name
    Box 2: Site
    Box 3:Reference Number

    and have all the information appear in a single comment as: Tom London 123 (If filled in as those details, naturally).

    An additional thing I'd like to do is take a string from checked form boxes as 0 or 1. So a Check, Check, No Check, Check would appear 1101.

    My end goal is to have a string I can use to create a barcode, so for this the examples above would be combines into Tom London 123 1101

    My issue is, I'm not much of a coder, and I have virtually zero knowledge of VBA. I know this is a lot to ask for, but I could really do with some pointers for how I could try to implement this.

    Thanks for your time.

    Edit: Word '13 -> Word '10 'cause brain wasn't co-operating
    Last edited by Lizardman; 2014-11-21 at 11:28. Reason: Typo, should be word '10

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Are these userform textboxes, ActiveX textboxes, text formfields - or something else?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    Are these userform textboxes, ActiveX textboxes, text formfields - or something else?
    Hi Macro, they're text form fields. Specifically, those found under the "legacy tools -> legacy forms" selection.

    The checkboxes are from the same location (Legacy Forms).

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    In that case, except for the checkboxes, all you need do to combine these into a string is to:
    note their internal bookmark names (or add them if missing);
    check their 'calculate on exit' property; and
    insert a series of cross-references, one for each bookmark name, wherever you want the string to appear. No VBA required.

    Doing anything with the checkboxes would require VBA however. The alternative is to use dropdown formfields instead. These also give you the ability to emulate a nul state, so you don't need to have a default checked/unchecked state. Indeed, if you only have a 4-digit binary string, all 16 possibilities could be encoded in a single dropdown. Similarly, if there are no more than 25 locations, using a Dropdown formfield for those eliminates the risk of input error.

    That's all you'd need from your formfields for the creation of a 3of9 barcode. Anything, though, else is liable to require VBA programming to convert your string into the particular barcode's data format.

    Assuming a 3of9 barcode is required, you may need to add field switches to the cross-references so as to ensure the text is converted to upper-case for barcoding, plus the start/stop asterisks the 3of9 barcode requires. Text formfield bookmarks are typically named 'Text1', Text2' etc. Similarly, dropdowns are named 'Dropdown1', 'Dropdown2', etc. For the purposes of a 3of9 barcode, you could combine these using field coding like:
    {QUOTE "*{REF Text1\* Upper}{REF Dropdown1 \* Upper}{REF Dropdown2}*" \* Charformat}
    and apply the 3of9 barcode to only the 'Q' in 'QUOTE'. See attached demo. As I don't have a barcode font installed, I've substituted a Wingdings font. To see the field coding, unprotect the document and press Alt-F9.
    Attached Files Attached Files
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    Lizardman (2014-11-26)

  6. #5
    New Lounger
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for all the information. It's given me a lot to work with. I'll be spending some time over the next few days to see if I can get everything to work as planned on my document.

    The whole field coding thing is new to me, so it could be interesting. I don't suppose you would know of a good guide to the syntax?

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    You might start by checking out 'Insert and format field codes in Word 2010': https://support.office.com/en-us/art...rs=en-US&ad=US
    and 'Field codes in Word': https://support.office.com/en-us/art...rs=en-US&ad=US

    To see how to do a wide range of calculations in Word, check out my 'Microsoft Word Field Maths Tutorial'*, at:
    http://windowssecrets.com/forums/sho...Maths-Tutorial

    To see how to do just about everything you might want to do with dates in Word, check out my 'Microsoft Word Date Calculation Tutorial'*, at:
    http://windowssecrets.com/forums/sho...ation-Tutorial

    There's also a lot of useful stuff in the 'Mailmerge Tips & Tricks'* thread, at:
    http://windowssecrets.com/forums/sho...ips-amp-Tricks
    Most of these are specific to mailmerges, but some have broader application, too.

    * These are all 'Sticky' threads at the top of this forum.
    Cheers,

    Paul Edstein
    [MS MVP - 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
  •