+ Reply to Thread
Results 1 to 32 of 32

Word Form - How to print a list of fields and drop down menu items

  1. #1
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Word Form - How to print a list of fields and drop down menu items

    Does anyone know how to print a list of the field names used in a form?

    Also would be good to be able to print (either as part of above or seperately) a list of items that are in the drop down menu fields.


    I'm aware there are some print options available in Tools > Options > Print but they don't fit the bill (that I can see!)
    Last edited by HighlandScott; 02-05-2009 at 07:51 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    This should get you started.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    I have created that Macro in the .dot template for the form.

    It appears to run but not change or display anything. I'm unclear what output I'm expecting?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Currently the output information is written to the immediate window in VBE

    ALT+F11 (VBE)
    CTRL+G (Immediate window)

  5. #5
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Thanks I can see that now I'm aware of the immediate window - I'm a bit of a novice with macros.

    Thanks a lot for your help that was very useful.

  6. #6
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Is there a way to amend the macro so it also includes values set on field options:
    Type
    Maximum Length
    Text format

    Can I also remove
    Default
    Actual


    And in an ideal world is possible to replace the output codes 70, 71, 83 with "Check Box", "Free Text", "Drop Down" - to make the output readable for normal people lol. I worked around by Find > Replace after copying the output to word.

  7. #7
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    The code is missing out some fields???

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    What type of fields? Post example file.

    The idea of the forum is you take the information and have a go yourself. Posting questions when you get stuck.

    Use the Object Browser (F2) in VBE and Intellisense to see what properties are available to use for a formfield object.

    To see other form type you need to extend the Select Case statement.
    And within a Case you can output a description of the type rather than a numeric value.

  9. #9
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    I mean the form fields on the word document itself. The fields the VB code should be referring to.

    What I mean is that I have, for example, 60 form fields on
    the document (i.e. text/date/list fields), yet the VB output randomly misses some fields and only gives me a list of say 45.

    Nothing wrong with the VB code that I can see.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Can you post example?

  11. #11
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    2 files attached. I have had to rename then to .xls because the forum has a 10kb limit on uploading .doc or .dot files.

    Example Form.xls
    Rename this to Example Form.dot
    This is the form itself. It has the fist macro you supplied inside it:
    Please Login or Register  to view this content.

    Data Fields Information (created manually).xls
    Rename this to Data Fields Information.doc
    This is a document I have created that lists all the form fields (field/bookmark name + actual description used on the form itself), type of field, and all items used in the drop down fields.
    There are 86 fields in total:
    Type No of Fields
    List 18
    Text 56
    Date 4
    Number 4
    Check Box 4
    Attached Files Attached Files

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    You are hitting a limit of the immediate window.
    It can only display ~200 lines.

    You .dot file has 86 Formfields and if you only output their names you can see all 86.

  13. #13
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Ah I see.

    Is there a way to output to a document instead of the "immediate window"?

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    You can write to a text file

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Many thanks Andy, that worked a treat.

    I amended the code to also include
    Print #intUnit, , "F1 Help Text:", objFormItem.HelpText
    This prints the help text saved against the field - accessed by the user by pressing F1 in the field.

    Problem is it only shows in the output text file the help text against standard text fields. Although there is help text against some lists and check boxes for some reason the script isn't picking it up? Any ideas?

    PS - the example I posted DOES NOT have help text. I have added it since.

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    This works for me.

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Thanks, but I've been messing around and think I've lost track of all the different bits of code. I'd be grateful if someone could join it all up into one piece that I can copy into visual basic.

    All I really need is:
    Field Name
    Field Type
    Drop Down List Options
    F1 Help Text

    I don't need Default or Actual Values.

    Just wish I had enough time to work it all out myself!

    Cheers

  18. #18
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Nobody able to help on this?

  19. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Seriously ?!?!

    You want somebody to do a cut and paste excerise because, to quote yourself, you don't have enough time.

  20. #20
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Not exactly. There's parts in the code I don't understand, and after copying and pasting myself it wouldn't work. If I knew which segments of code I needed and in what order and knew what conditions and statements to make then I'd do it. I meant I don't have time to learn enough about VB in order for me to even know what to copy and paste.

  21. #21
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Why not post what you do have, explaining what's not working.

  22. #22
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    I'm currently using:
    Sub DumpForms()

    Dim objFormItem As FormField
    Dim objItem As ListEntry
    Dim strFileName As String
    Dim intUnit As Integer

    strFileName = "C:\temp\FormField.log"
    intUnit = FreeFile
    Open strFileName For Output As intUnit

    For Each objFormItem In ActiveDocument.FormFields
    Print #intUnit, objFormItem.Name, objFormItem.Type
    Select Case objFormItem.Type
    Case wdFieldFormDropDown
    For Each objItem In objFormItem.DropDown.ListEntries
    Print #intUnit, , objItem.Name
    Next
    Case wdFieldFormTextInput
    End Select
    Next

    Close intUnit

    End Sub
    This provides me with an output (example of 9 fields):
    EDEmployeeType 83
    Select from list:
    NEW STARTER
    EXISTING EMPLOYEE
    EX-EMPLOYEE RETURNING TO THE COUNCIL
    EDEmployeeNumber 70
    EDContractType 83
    Select from list:
    PERMANENT
    FIXED TERM
    SEASONAL
    RELIEF
    TEMP COVER
    PHDHoursFullTime 71
    PHDHoursWeek1Mon 70
    PHDHoursWeek1Tue 70
    PHDHoursWeek1Wed 70
    PHDHoursWeek1Thu 70
    PHDHoursWeek1Fri 70

    My requirements have changed slightly. The above output format is all I need - but if possible I'd like to substiture the numbers that represent the type with the following:
    70: (Text)
    83: (Drop Down List)
    71: (Check Box)

  23. #23
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Not tested
    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Thanks Andy, it works great. But I've made a couple of tweeks to it:

    It was giving me "FALSE" as a check box value:
    Please Login or Register  to view this content.
    To try and remove the "FALSE" changed
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    But all that did was change the "FALSE" to "TRUE"
    Please Login or Register  to view this content.
    So I then removed the bit of code completely
    Please Login or Register  to view this content.
    And it worked fine giving me
    Please Login or Register  to view this content.

    Complete script now:
    Please Login or Register  to view this content.

  25. #25
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    Was the checkbox ticked?

  26. #26
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    No, not at any time. I couldn't understand why the script output changed between FALSE/TRUE, but the check box has never been ticked at any point.

  27. #27
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    The value property will return FALSE (not ticked) or TRUE (ticked).

    When you leave .Value off of the command the Default property will be used.
    I'm not sure what the default property is but it would appear not to be the Value.

    What did you expect to see as output, if not TRUE or FALSE ?

  28. #28
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Quote Originally Posted by Andy Pope View Post
    The value property will return FALSE (not ticked) or TRUE (ticked).
    I know

    Quote Originally Posted by Andy Pope View Post
    When you leave .Value off of the command the Default property will be used.
    I'm not sure what the default property is but it would appear not to be the Value.
    I understand what you're saying

    Quote Originally Posted by Andy Pope View Post
    What did you expect to see as output, if not TRUE or FALSE ?
    I don't think you've understood me quite right somewhere. If I expected an output I would expect TRUE or FALSE. There just seemed to be no apparent logic to why it changed, without the real checkbox value being changed.

  29. #29
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    I thought I understood.
    Are you saying that the T/F output varied between runs without you changing either the checkout or the code?

    I can see the reason for the change between code changes as the code is reporting different things.

  30. #30
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Using the last full script you gave me reported the value as FALSE (Correct).

    I then (guessed) to remove the ".Value" from the end of this line:
    Please Login or Register  to view this content.
    That's when it starting reporting the value as TRUE. There was no other change to the data or the script. You suggested this may result in the default value being printed, but this default obviously isn't the value. This seems correct (value is and always has been FALSE). Why it prints a value at all after removing ".Value" is another question.

    At this point I removed the entire line
    Please Login or Register  to view this content.
    And that solved the problem as far as the output I require. I don't want any value at all.

  31. #31
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Word Form - How to print a list of fields and drop down menu items

    I did not say default value I said default property , subtle difference.

    If you use the object browser (F2) you will see that the default member for a checkbox is actually the Valid property.

    and the help says,
    Valid Porperty:
    True if the specified form field object is a valid check box form field. Read-only Boolean.

  32. #32
    Registered User
    Join Date
    08-06-2008
    Location
    Inverness, Highlands, Scotland
    MS-Off Ver
    2002 (Work)
    Posts
    34

    Re: Word Form - How to print a list of fields and drop down menu items

    Sorry, yes it was Property. I've had a look at the object browser and help, and won't claim to understand everything your saying or I'm reading but I get the idea.

    Thanks for your help on everything. This code will save me plenty time on a few form projects I've got going or coming up. Then hopefully I'll not have to touch Word again for a few years....and get back to my spreadsheets and databases!

+ 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