#  Other Applications & Softwares  > Word Formatting & General >  >  Word Form - How to print a list of fields and drop down menu items

## HighlandScott

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!)

----------


## Andy Pope

This should get you started.




```
Please Login or Register  to view this content.
```

----------


## HighlandScott

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?

----------


## Andy Pope

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

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

----------


## HighlandScott

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. :Smilie:

----------


## HighlandScott

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.

----------


## HighlandScott

The code is missing out some fields???

----------


## Andy Pope

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.

----------


## HighlandScott

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.

----------


## Andy Pope

Can you post example?

----------


## HighlandScott

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

----------


## Andy Pope

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.

----------


## HighlandScott

Ah I see.

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

----------


## Andy Pope

You can write to a text file




```
Please Login or Register  to view this content.
```

----------


## HighlandScott

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.

----------


## Andy Pope

This works for me.




```
Please Login or Register  to view this content.
```

----------


## HighlandScott

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

----------


## HighlandScott

Nobody able to help on this?  :Frown:

----------


## Andy Pope

Seriously ?!?!

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

----------


## HighlandScott

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.

----------


## Andy Pope

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

----------


## HighlandScott

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
> ...



This provides me with an output (example of 9 fields):




> EDEmployeeType               83               Select from list:
>               NEW STARTER
>               EXISTING EMPLOYEE
>               EX-EMPLOYEE RETURNING TO THE COUNCILEDEmployeeNumber             70 
> EDContractType               83               Select from list:
>               PERMANENT
>               FIXED TERM
>               SEASONAL
>               RELIEF
> ...




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)*

----------


## Andy Pope

Not tested



```
Please Login or Register  to view this content.
```

----------


## HighlandScott

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.
```

----------


## Andy Pope

Was the checkbox ticked?

----------


## HighlandScott

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.

----------


## Andy Pope

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 ?

----------


## HighlandScott

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



I know





> 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





> 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.

----------


## Andy Pope

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.

----------


## HighlandScott

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.

----------


## Andy Pope

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.

----------


## HighlandScott

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!

----------

