Hello, I have received a document with a ton of fields. I would like to find a way to extract the field names and properties to a separate list for review. Can this be done? I'm using Word 2002. Thanks in advance for any guidance.
Hello, I have received a document with a ton of fields. I would like to find a way to extract the field names and properties to a separate list for review. Can this be done? I'm using Word 2002. Thanks in advance for any guidance.
You could use this macro, which lists all fields in the document in the immediate window. You can cut and paste from there. Sub ListFields() Dim pfield As Word.Field Dim pRange As Word.Range For Each pRange In ActiveDocument.StoryRanges Do For Each pfield In pRange.Fields Debug.Print pfield.Code, pfield.Type, pfield.Kind Next Set pRange = pRange.NextStoryRange Loop Until pRange Is Nothing Next End Sub
Hi Lincoln, The following code generates a list of all bookmarks at the end of the active document, and displays their contents. If you need to do more, you could incorporate other fields by changing ActiveDocument.Bookmarks to ActiveDocument.Fields, though some (eg Date) won't have names. Cheers Sub GetBkMrks() If ActiveDocument.Bookmarks.Count > 0 Then For Each oBmk In ActiveDocument.Bookmarks With Selection .EndKey Unit:=wdStory .InsertAfter oBmk.Name & " " .EndKey Unit:=wdStory oBkMrk = ActiveDocument.Fields.Add(Range:=Selection.Range, Text:=oBmk.Name, PreserveFormatting:=False) .InsertAfter vbCrLf End With Next oBmk End If End Sub --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system ( http://www.**--****.com/ ). Version: 6.0.593 / Virus Database: 376 - Release Date: 20/02/2004
Substituting 'Fields' for 'Bookmarks' won't work with this code. First, fields don't have a Name property, so you won't get any output, just errors. Second, it would miss all the fields not in the body of the document (eg headers, footers, footnotes, textboxes, etc).
1.Using control values within IF field
Hello, I'm using Word2003 and I would like to use the result from a check box (i.e. True or False) in an IF field/function, but don't know how to. I've gone as far as typing the following, which doesn't work: IF (Checkbox(Customer).value=true,YES,NO) I would also like the field to update automatically when the check box value changes. Any suggestions would be greatly appreciated ! thanks in advance
2.using an alphanumeric "word" as a field value in an IF statement
I am attempting to create an IF THEN ELSE statement where the field value I'm selecting by is alpha numeric. For example, if I have "06s1" in the compare to field, the merged document will always insert the "then" option. If I modify it and have "06-s-1" in the compare to field, the funtion works properly an inserts the appropriate option - then or else. Is there some coding I can do so that the function can recognize a "word" with both numbers and letters in it?
3.Can I compare more than two merge field values using =AND or =
Thanks Doug.That may, unfortunately, be where I'm at. I'm hoping there's an alternative because I'm already close to the max number of columns in the data source, and I need to compare the mergefields in multiple, unique combinations, which is why I'm hoping to do it in the word doc itself. Thanks again! "Doug Robbins - Word MVP" wrote: > I would suggest that you do the comparing in the data source, moving the > data to Excel of Access to do so if necessary. Both of those programs are > better at manipulating data than Word. > > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP, originally posted via msnews.microsoft.com > "Rhiannon" < XXXX@XXXXX.COM > wrote in message > news: XXXX@XXXXX.COM ... > > I'm working in Word 2007. I have a list of mergefields (anywhere between 3 > > and 7 depending) that I would like to test the values of - if all of them > > come back true, return one block of text, else return another block of > > text. > > It works fine when I try and compare the values of two mergefields: > > > > {IF { = AND ( { COMPARE {Mergefield 1} = "Y"}, {COMPARE {mergefield 2} <> > > 2 > > } ) } = 1 "true" "false" } > > > > but as soon as I try and compare the values of three or more mergefields: > > > > {IF { = AND ( { COMPARE {Mergefield 1} = "Y"}, {COMPARE {mergefield 2} <> > > 2 > > }, { COMPARE {mergefield 3" = "text" } ) } = 1 "true" "false" } > > > > it breaks. Is there a way to expand beyond two comparisons, using either > > the > > =AND or the =OR formulas? I'd rather not start nesting piles of these if I > > can help it. Thanks muchly!! > >
4.How do I save a file using the value entered in a text form field
I have a word document that myself and others on my team must fill out repeatly. I created a simple template for the basic form to automate the process, I would like to automate the "Save As" file name using date from one of the "Text form Fields". the file name would be "SW_COA_XXXXXX_johnson.doc". The XXXXXX would be the numeric value entered in Text Form Field labeled "Text 2". Can this be done? Scott
5.Validating field values using an array
The code below is sliced out of my latest efforts. I have a form with some fields that are mandatory and ortehrs not. to test them I am trying to use an array with the names of the mandatory fields. But it will only ever report invalid even when it shold be OK. I#m sure it's something simple that i can't see for looking. Can anyone spot the problem? ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Initialise the mandatory fields array etc. ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ valuesMandatoryFields() = Array _ ("DocTitle", "DocSubject", "DocAuthor", "DocPublicationStatus", "DocVersion", "DocType") ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Check each field ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For Each conControl In Me.Controls If LCase(TypeName(conControl)) = "textbox" Then 'strMsgInsert = conControl.Name ' debug 'MsgBox "checking field " & strMsgInsert, vbOKOnly If IsFieldMandatory(conControl.Name) = True Then ' it's a mandatory field If Not Len(Trim(conControl.Text)) > 0 Then ' and they haven't entered anything so booEntryValid = False ' set flag so that returns to user End If End If End If Next ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Either exit to process valid or return invalid to user ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If booEntryValid = True Then MsgBox "all Ok" Me.Hide ' valid entry so return control to calling module Else ' invalid entry ask them to try again MsgBox "You have not entered one or more of the mandatory field please try again" DocTitle.SetFocus 'set focus to first field before returning control to user End If The Function is like this: Private Function IsFieldMandatory(varFieldToTest) As Boolean For Each varMandatoryField In valuesMandatoryFields IsFieldMandatory = (varMandatoryField = varFieldToTest) Next End Function thank you luca
6. change drop down list contents based upon value from another list
Users browsing this forum: No registered users and 11 guest