Basic VSTO questions

I have an MS Word VSTO 2005 application that uses XML tags.  I put custom controls on the ActionPane to navigate a SQL table and update the Word file as the user scrolls through records.  All of that works, for the most part.  I just have three questions I haven't been able to figure out:

- What if I want to start the Word document on a specific record   How can I pass some sort of parameter to the document class to tell it which record to start on

- It is possible to get the Word document to repeat itself for each record in the table, like a mail merge does

- Why is it that only the first occurrence of an XML tag gets filled in when you use the LoadXML() function   If I do a mail merge and repeat the same field multiple times on the page, all of the occurrences of that field get filled in properly.

TIA,

Mike Rodriguez


Answer this question

Basic VSTO questions

  • DJE_1

    Hi,

    so is ist possible to LoadXml so that data in word reflects the changes in my xml-dom

    regards

    almir



  • NintendoGameCubeRulez

    Mike,

    Wow, this post has sat here for entirely too long. You are probably retired by now but here is an answer anyway, and I'm sorry we too so long to answer:

    If by "start the Word document on a specific record" you mean:

    a) connecting to a datasource on document load

    b) retreiving records

    c) using retreived data to populate the document

    then, you can use the Document_Load event. You will do all of these operations before the Action pane gets loaded or displayed.

    If by "Word document to repeat itself" you mean to have the contents of a document be completely altered repeatedly depending on the data retreived from an external source, then the answer is, yes. You can do this. I recommend having a schema tied to the document. You can then link targeted areas of the document to specific elements in your schema. You then bind data to the elements in the schema, and they will be reflected in the targeted areas of the document. These are very well demonstrated in the Word XML SDK on MSDN. I have listed loads of Word dev resources here:

    http://blogs.msdn.com/johnrdurant/archive/2005/12/16/word_developer_resources.aspx

    As far as only having one tag getting filled when you load the doc, it is not clear to me what is going on in your solution, so I cannot hazard a very good guess for you. Please let me know more about your solution, and I'll answer it for you. Also, checking out the SDK will help you get a better handle on the fundamentals under the hood with Word XML.

    I'll leave this question open during this week to give you a chance to respond with more detail. Otherwise, I'll just close it next Monday. I look forward to hearing from you.

    HTH!

    John.



  • mike g.

    I can help on the LoadXML one tag thing. LoadXML is a method we added to the XMLNode Word controls in VSTO. It has a limitation--it will not decrease or increase the number of XML elements in the document.

    Excerpting from my book for a second (cause I'm lazy):

    "LoadXml has one major limitation. It will not decrease or increase the number of XMLelements in the document. So given the code in Listing 22-7 that has three book elements and given a document that has only one book in the table mapped to book elements, LoadXml will only transfer the first book to the document. To transfer the second and third book would require the addition of elements, which LoadXml does not do. As a second example, if you have a document that has three books in the table and you call LoadXml passing XML with only one book, LoadXml will update the first row of the table but will leave the two extra books there. The second and third books are left there because LoadXml does not remove elements."



  • Basic VSTO questions