Manipulate Bookmarks @ Server Side

[Using VSTO 2005 Beta 2]

I am looking for a way to change text within Word Bookmark controls at the server.

I am aware of accessing the Cached objects within the Word Manifest and for instance fill a Cached Dataset with the information that I want to show in bookmarks.

What I would like to know is if it's possible to change bookmark information directly using a ServerDocument.

The Other thing, is it possible to databind Bookmark controls to a cached data object so that changing data in the cached object is enough to change de bookmark contents

The reason for all of this is that the information is at hand at the serverside and it is needed that no further processing is needed at the client side.

-= Maarten =-
http://blogs.officezealot.com/maarten



Answer this question

Manipulate Bookmarks @ Server Side

  • DBNull

    Hi Maarten,

    To my knowledge the ServerDocument class does not expose any methods or properties that would allow you to edit the text within a bookmark.

    You can however, bind the bookmark control to a field within the dataset and if you then update the data within the cached dataset the bookmark control should display the updated data.

    Regards,

    Ken Laws
    MSFT

    This posting is provided "AS IS" with no warranties, and confers no rights.

    For more information regarding Visual Studio Tools for Office 2005:

    Best of Blogs: Visual Studio 2005 Tools for Office
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/odc_2003_ta/html/odc_landvsto2005_ta.asp

    Visual Studio Tools for Office Forum
    http://forums.microsoft.com/msdn/ShowForum.aspx ForumID=16

    Visual Studio Tools for the Microsoft Office System
    http://msdn.microsoft.com/office/understanding/vsto/default.aspx


  • Murad YAGLI

    The point is that the datasource is only a 'placeholder' until accessed and filled using the ServerDocument interface.

    -= Maarten =-



  • Oddbjørn Sjøgren

    If the datasource being cached is an existing datasource, for example, a SQL Server table or query, then you could add the datasource to the project, add the bookmark controls and then databind the bookmark controls to the fields in the datasource which would allow you to set the databindings at design time.

    If however, you are dynamically creating a dataset and datatable(s) at runtime then you may need to dynamically set the databinding for the bookmark controls at runtime.

    If you have any questions please let me know via the posting.

    Regards,

    Ken Laws
    MSFT

    This posting is provided "AS IS" with no warranties, and confers no rights.

    For more information regarding Visual Studio Tools for Office 2005:

    Best of Blogs: Visual Studio 2005 Tools for Office
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/odc_2003_ta/html/odc_landvsto2005_ta.asp

    Visual Studio Tools for Office Forum
    http://forums.microsoft.com/msdn/ShowForum.aspx ForumID=16

    Visual Studio Tools for the Microsoft Office System
    http://msdn.microsoft.com/office/understanding/vsto/default.aspx


  • Wessty

    I was able to insert a cached dataset and update the dataset as ServerDocument.
    The binding was set programmatically and enabled the update of the bookmark in the document.

    What I did is:

    Add a cached dataset to the ThisDocument class:

    [Cached()] public DataSet myDS;

    and set the binding in the ThisDocument_Startup:

    private void ThisDocument_Startup(object sender, System.EventArgs e)
    {
       if (myDS == null)
       {
          myDS = new DataSet
    ();
           DataTable
    myTable = new DataTable("Table1");
          myTable.Columns.Add("Column1", typeof(string));
          myDS.Tables.Add(myTable);
       }
       bookmark1.DataBindings.Add("Text", myDS, "Table1.Column1", true);
    }

    A new question that came to me was:

    Is it possible to make the Databinding persistent instead of setting this each time at Startup If so how/where



  • FrankBru

    If adding the bookmarks to the document at design time is an option, then you could add the bookmark controls to the document and then set the databinding properties in design time which would persist the setting and prevent you from having to set the databinding at runtime.

    Regards,

    Ken Laws
    MSFT

    This posting is provided "AS IS" with no warranties, and confers no rights.

    For more information regarding Visual Studio Tools for Office 2005:

    Best of Blogs: Visual Studio 2005 Tools for Office
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/odc_2003_ta/html/odc_landvsto2005_ta.asp

    Visual Studio Tools for Office Forum
    http://forums.microsoft.com/msdn/ShowForum.aspx ForumID=16

    Visual Studio Tools for the Microsoft Office System
    http://msdn.microsoft.com/office/understanding/vsto/default.aspx


  • Brendan77655

    If you have added a datasource to the project then you should be able to simply drag and drop a field from the datasource to the document to create a bound bookmark control.

    Otherwise adding the bookmark control and setting the databinding to the field in the datasource should work.

    Regards,

    Ken Laws
    MSFT

    This posting is provided "AS IS" with no warranties, and confers no rights.

    For more information regarding Visual Studio Tools for Office 2005:

    Best of Blogs: Visual Studio 2005 Tools for Office
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/odc_2003_ta/html/odc_landvsto2005_ta.asp

    Visual Studio Tools for Office Forum
    http://forums.microsoft.com/msdn/ShowForum.aspx ForumID=16

    Visual Studio Tools for the Microsoft Office System
    http://msdn.microsoft.com/office/understanding/vsto/default.aspx


  • code-breaker

    In fact that was what I tried first. Adding the bookmark and enter the binding in the properties pane. The properties pane however refused to accept the params to bind to the Cached dataset. That's why I added the binding code in the initialize on the document...

    Maybe I missed how to do that in design time...


  • Jack Lavender

    The dataset is situated (see my earlier post) in the ThisDocument class and is created one time. All other manipulations will be done externally by streaming the xml data into the document using the ServerDocument interfaces.

    Thanks for your support, it helped me create a nice demo.

    -= Maarten =-



  • Manipulate Bookmarks @ Server Side