Difficulty assessing state of field 
Author Message
 Difficulty assessing state of field

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



Thu, 29 Dec 2005 19:48:45 GMT  
 Difficulty assessing state of field
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



Fri, 30 Dec 2005 06:19:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Difficulty assessing state of field - Attention Doug Robbins

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

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

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

5. Assessing Document Properties

6. Assessing an Access report through VB.

7. Y2K tool to assess,remediate visual basic tool for Y2k compliance

8. VB remote assess programmer

9. assessing VBX/DLL overhead

10. ADO Connection State Does Not Reflect Actual Connection State

11. Assessing NT Server Manager Info

12. How to populate a combo box with data from a pocket assess table

 

 
Powered by phpBB® Forum Software