How to "take" current page and put data into bookmark? RRS feed

  • Question

  • I've managed to create and show in "Word.dotx" file an ActionPaneControl. Now I am trying to get bookmarks from the "Word.dotx" file from code-behind ActionPaneControl. What I call bookmarks are just strings in the quotes("bookmark1", "bookmark2", "bookmark3"):

    Hello, World!  "Bookmark1" is trying to improve his coding skill in VSTO. He like playing "bookmark2", moreover he likes spending time reading books. For example, "bookmark3"  and it is the favourite book of "Bookmark1".

    My question is how can I get bookmarks and replace text from codebehind of ActionPaneControl?

    I've tried this code, but I even compile it:

            private void button1_Click(object sender, EventArgs e)
                Document vstoDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    and error message says:

    Error 1 'MyAppl.ActionPaneControl' does not contain a definition for
    'Application' and no extension method 'Application' accepting a first argument of type 'MyAppl.ActionPaneControl'' could be found (are you missing a using directive or an assembly reference?)

    Sunday, December 13, 2015 5:55 PM


All replies

  • GetVstoObject is not used/required in a document-level solution. The VSTO document is already an object in your solution. See the following page:

     For assigning content to a bookmark, see this page in the VSTO documentation

    Cindy Meister, Office Developer/Word MVP, <a href=""> my blog</a>

    Sunday, December 13, 2015 6:28 PM
  • thanks for your reply, Cindy Meister.
    Yeah, I've read the articles all of them . Sorry for misleading  and for my little knowledge of VSTO. 

    What I want is not to change bookmark from code - behind of ThisDocument.cs, but from ActionsPaneControl1_Load and to be more accurate to change from button event handelr. I have an image what I have now:

    That is, an user inputs data to textboxes and then clicks a button "Insert bookmarks into Word". 

    Is it possible? How can I change Bookmarks from ActionPaneControl? Any help would be greatly appreciated.

    • Edited by NiceStepUp Sunday, December 13, 2015 7:13 PM
    Sunday, December 13, 2015 7:11 PM
  • Researching the documentation would help you move along more quickly...

    Cindy Meister, Office Developer/Word MVP, <a href=""> my blog</a>

    • Marked as answer by NiceStepUp Sunday, December 13, 2015 7:52 PM
    Sunday, December 13, 2015 7:23 PM