Re: Glitch in GetCrossReferenceItems

Tech-Archive recommends: Fix windows errors by optimizing your registry



Okay, how about this? I tweaked your for loop just a bit to show what's in
the container. By using trim, the blank heading came back as 0!

For I = 1 To UBound(varXrefs)
Selection.InsertAfter varXrefs(I) & vbNewLine
MsgBox Len(Trim(varXrefs(I)))
Next I

"Bear" wrote:

zkid:

Alas, no. The container is returned with no empty elements. For example, if
I had ten headings, but one was blank, the getcrossreferenceitems method
fills my variant (array) with nine items.

Sigh.

Bear

PS: Thanks for trying so hard. I appreciate it.
--
Windows XP, Word 2000


"zkid" wrote:

Bear, when you load the list box from the cross-reference container, you can
use a for loop to check to determine if each entry is empty, yes? Then, if
so, don't load it into the list box. Will that work?

"Bear" wrote:

Shauna:

Obviously, I'd appreciate any help you can provide. I'm at the point of
considering if there's any way to perform a test each time the user attempts
to insert a cross-reference, just to warn them that the x-ref they just
inserted was incorrect. But I don't know of a good way to actually examine
the x-ref just inserted.

Bear
--
Windows XP, Word 2000


"Shauna Kelly" wrote:

Bear

I can repro your problem exactly as you describe it. Give me a little
while (that's deliberately vague, but it probably means a day or two) to
see if I have any code lying around the place that might help.

But I suspect there's no way around this.

Shauna

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word




"Bear" <david.chinell@xxxxxx(nospam)> wrote in message
news:0B013163-0CCF-4F34-B96D-C6EAF7DC38B1@xxxxxxxxxxxxxxxx
I hope Shauna reads this. Just one more oddity about
GetCrossReferenceItems
and InsertCrossReference. But maybe you've found a way around it...

You can test this out yourself fairly easily. Create a document with
three
Heading 1 paras in it. Type Before in the first, nothing in the
second, and
After in the third.

GetCrossReference items will not include the empty para! (If it's a
Heading
2 or 3 etc, it will -- it just skips empty Heading 1 paras.)

This means that if I fill a listbox with GetCrossReference, let the
user
pick one, and use the listbox index to specify the
InsertCrossReference item,
everything after the blank para will be off by one. You try to insert
Title 7
and you get Title 6 etc.

I can't think of any efficient way to stop this, or even warn the user
that
something's amiss. (Typically it's because a section break gets styled
as
Heading 1.)

Any ideas?

Bear
--
Windows XP, Word 2000



.



Relevant Pages

  • Re: Glitch in GetCrossReferenceItems
    ... The container is returned with no empty elements. ... I had ten headings, but one was blank, the getcrossreferenceitems method ... Heading 1 paras in it. ... InsertCrossReference item, ...
    (microsoft.public.word.vba.general)
  • Re: Automatic Cross-references
    ... The document had a blank line with a heading style. ... I tried to add a test for a blank xref, but does GetCrossReferenceItems does ... 'Declare arr_Xrefs ... InsertCrossReference method must *explicitly* be a Variant." ...
    (microsoft.public.word.vba.general)
  • Re: Glitch in GetCrossReferenceItems
    ... Heading 1 paras in it. ... GetCrossReference items will not include the empty para! ... InsertCrossReference item, ...
    (microsoft.public.word.vba.general)
  • RE: Glitch in GetCrossReferenceItems
    ... heading styles ARE considered numbered items - you'll just have to ... Dim varXrefs As Variant ... I've been putting a break point at the beginning of the InsertCrossReference ... GetCrossReferenceItems simply skips that para and keeps on filling the array ...
    (microsoft.public.word.vba.general)