binding in Word documents
Hi guys,As you probably saw I am having difficulties display bookmark controls that are directly binded to some binding source. I get a strange message, the reason of which I still look for an answer.
So after reviewing once again the excellent webcast - Data Binding Relational Data in Visual Studio 2005 Tools for the Microsoft Office System from Janet Robinson - it occurred to me that nowhere in this webcast was shown how to directly bind table in Word document. Janet used XML nodes instead. She used one additional step to extract the XML from the dataset and load it in the XML root node of the Word document. However, in my opinion, we are losing all the benefits of using binding contexts. I had to write more code in PositionChanged event of the binding navigator that I used. The code basically took the current record in the binding source and created a new dataset with only one row. After that I extracted the XML and loaded it into document’s root node. It is clear that there is no more automatic binding for my word document since the extracted xml has to be refreshed every time my binding source changes.
Please tell me how to proceed. What am I doing wrong or is this the expected behavior?
Hope it is clear enough to understand the problem.
If you have any questions, please ask.
Thanks,
Martin Kulov
http://www.codeattest.com/blogs/martin
Hi Martin,
Unfortunately as Janet mentioned in the web cast that you referenced, there aren't any host controls for Microsoft Word that provide complex data binding and as a result in order to retrieve and display an entire record you must write additional code in order to retrieve and display the data within Microsoft Word.
In the web cast Janet used XML nodes to populate a Microsoft Word table with data from the Northwind Shippers table and as she noted the data that was returned to the table is not bound to the dataset, it is static data. So you are correct in that if you wanted to loop through the dataset and display a row of data within Microsoft Word that you would need to implement additional code that would allow you to retrieve the current record and then populate the table with this data.
Now to answer your question; because there isn't a host control for Microsoft Word that provides complex data binding the behavior that you are seeing, if I have understand your question correctly, is by design.
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
Hi Ken,
Thanks for your answer. I got the idea in the meantime after watching the Janet's webcast one more time :).
Are there any plans to provide such control in future releases?
Thanks again,
Martin Kulov
http://www.codeattest.com/blogs/martin
PS: man, this html editor is such a ***. I have edited this message dozens of times to get the formatting right.