-1

I have been trying to split a word document to pages. A through POC that led to the fact that this cannot be done through Apache POI, and consequently made me resort to JACOB to invoke MS Word as a proxy to achieve such transformation.

I have made some reasonable advancements with my code, now I am able to open a document, search, replace, and so on. However I am unable to get the "page" bookmark

            ActiveXComponent oDocuments = oWord.getPropertyAsComponent("Documents");
        ActiveXComponent oDocument = oDocuments.invokeGetComponent("Open", new Variant(sInputDoc), new Variant(false));
        ActiveXComponent oSelection = oWord.getPropertyAsComponent("Selection");

        ActiveXComponent oBookmarks = oSelection.getPropertyAsComponent("Bookmarks");
        int bookMarksnumber = oBookmarks.getProperty("Count").getInt();
        System.out.println(bookMarksnumber);

This always returns 0 (If the same can be achieved using POI I am open to all suggestions)

WiredCoder
  • 916
  • 1
  • 11
  • 39

1 Answers1

0

use this to achieve bookmarks

ActiveXComponent oBookmarks = oDocument.getPropertyAsComponent("Bookmarks");
  • Please edit with more information. Code-only and "try this" answers are discouraged, because they contain no searchable content, and don't explain why someone should "try this". – abarisone Jul 22 '16 at 06:44
  • Thanks for the update, this one worked for me, still my problem is not resolved unfourtunatly – WiredCoder Jul 25 '16 at 09:07