Giter Club home page Giter Club logo

Comments (4)

boar24 avatar boar24 commented on August 10, 2024

Hi, glad you like it.

Can you please provide a file for me to download which shows the effect so that I can have a look at it.

Best regards

from insertcrossreferencescomfortably.

QvS1 avatar QvS1 commented on August 10, 2024

Hi, thanks for the reaction.

hereby an example file.

crossrefmacro_example.docx

Regards,
QvS1

from insertcrossreferencescomfortably.

boar24 avatar boar24 commented on August 10, 2024

Hi, thanks for the very helpful example file with which I could easily reproduce the effect.

I now had a look into the code to see what happens.
It turned out that Microsoft's call .GetCrossReferenceItems() only presents the cross references (XRefs) which are plain inside the document body, but not those which are in those Textboxes.
I tried a workaround (see below) but that didn't work either.
I had to give up and will close the issue.
I would recommend that you remove those textboxes if you want to use my macros.
Sorry for not having better news. Best regards

        ' Regarding the issue that crossrefs are only found in the document body,
        ' but not if they are within Textboxes:
        '
        ' Microsoft says (https://learn.microsoft.com/en-gb/office/vba/api/word.selection.insertcrossreference)
        ' that <Selection.InsertCrossReference()> can be used with <ReferenceItem> where
        ' "this argument specifies the item number or name in the Reference type box in the Cross-reference dialog box".
        ' We have found out, that the dialog box
        ' - first lists the cross references in the document body (wdMainTextStory ?)
        ' - then  lists the cross references in the text boxes (wdTextFrameStory).
        ' This is true independent of the order of the elements in the document, so:
        ' first all Xrefs in the document, then all Xrefs in the TextFrames.
        '
        ' Idea therefore: if the XRef was not found in the document body, then search in the TextFrames.
        ' This is what the below code does. It finds the XRef and returns the index,
        ' i.e. the ordinal of the XRef within the TextFrame XRefs.
        ' Then if we add this ordinal to the number of XRefs in the document body,
        ' we exactly get the "item number [..] in the Cross-reference dialog box", i.e. the Index. Sounds good so far.
        ' However, when pass this Index to <Selection.InsertCrossReference()> to actually insert the XRef,
        ' then this function crashes, apparently believing that the given index is out-of-bounds.
        ' So there is currently no solution. :-(

from insertcrossreferencescomfortably.

QvS1 avatar QvS1 commented on August 10, 2024

Hi, Thanks for taking the time looking in to this query.

Cheers,

QvS1

from insertcrossreferencescomfortably.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.