Difficulty assessing state of field - Attention Doug Robbins 
Author Message
 Difficulty assessing state of field - Attention Doug Robbins

Thanks Doug for your reply.
The solution you suggested picks up if the tools.options is toggled to
ShowFieldCodes ON.
I did not say - I am using Office 2000 on a Win2K platform.

It is hard for me to experiment with the problem, as it occurs only
occasionally. The options.showfieldcodes setting is always set to false, and
is not the cause for the field to be visible as a field. It is not clear why
it is occasionally visible as a field.
The whole story is this.
The original document is a patient's medical notes - embedded in which are
various tools. One of these is a letter writer.  A macro field is double
clicked and a new document based on a template called MedLet is opened.  In
Medlet is this command to pull across a list of the medications the patient
is taking, as listed and bookmarked in the calling document, in table form.
Code then transforms this to a simplerand more relevant list, first
assessing whether a table is present to know if there are in regular
medications listed for the patient.  If a table is not present then the
changes are wound back and the user receives a message that the patient does
not have any medications in their list.
Sometimes, with no difference in use, this bookmark field is left in field
rather than result form, triggering the error path and message that no
medications are listed.  If this happens it requires, I think as I have not
had much opportunity to experiment, a complete shut down of Word and a
restart to stop it happening in a particular document. (I think that you
could imagine that a patient who was consulting me would not look very
kindly on me asking him/her to wait 30 mins while I experiment with various
options to see why this little piece of code is malfunctioning in their
particular file!).
This is why I was trying to look at the specific field in question and
assess it's state rather than the state of the whole document.

Does this make any sense?
Any ideas?

thanks again
Brett

Hi Brett,

Use the following to ensure that the display of field codes is turned off

    If ActiveWindow.View.ShowFieldCodes = True Then
        ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
    End If

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hi all.  Hope someone can help me with this.
> I use the following code to pull a bookmark that marks a table from an
open
> document to the active document.

> WhichDoc$ = ActiveDocument.Variables("WhichPath").Value
> ActiveDocument.Fields.Add Range:=Selection.Range,

Type:=wdFieldIncludeText,
Quote:
> Text:=Chr(34) + WhichDoc$ + Chr(34) + "MedicationList" + Chr(34)
> With Selection
>     .Fields.Update
>     .GoTo What:=wdGoToField, Which:=wdGoToPrevious, Count:=1
>     If .Information(wdWithInTable) = True Then

> The last line is to assess if the table was present, or whether the
bookmark
> was empty or marked something unrelated (error in the structure of the
> document which is being referenced).

> The problem is if the after insertion the field is toggled to show the
field
> code rather than the field result then the result is never within a table.
> I'm not sure why this happens - usually it will appear as the field
result,
> but sometimes the field code appears.
> Now, if I could assess if it was the field code that was visible before
> assessing the wdWithInTable) this would not be a problem, but if I use
>     .Fields(1).ShowCodes
> to assess the field state an error is trigger saying that "The requested
> member of the collection does not exist."
> For some reason, even though a field is present,

ActiveDocument.Fields.Count

- Show quoted text -

Quote:
> is 0.

> Is there a way to assess the state of a selected field to know its state,
or
> can someone suggest another way around this.
> I've tried using the document object to pull across the content of the
> bookmark, but it comes across as text, not the original table.

> Many thanks in advance.
> Brett



Mon, 02 Jan 2006 17:31:19 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Difficulty assessing state of field

2. Question for Doug Robbins

3. 10 out of 10 to Mr. Doug Robbins - Creating a userform

4. 10 out of 10 to Mr. Doug Robbins - Creating a userform

5. Multiple Page Print--Doug Robbins - Word MVP

6. ATTENTION, ATTENTION: PLEASE HELP!!!!!!!!!!!!!!!!!!!!

7. ATTENTION, ATTENTION: PLEASE HELP!!!!!!!!!!!!!!!!!!!!

8. Attention anyone in the Physics field!

9. Putting a space between state and zip in a field

10. HELP!!!! Taking apart City-State-Zip field problem

11. City, State ZIP in one field - Crystal 6

12. Assessing Document Properties

 

 
Powered by phpBB® Forum Software