Reading the OneNote schema documentation helps prevent bugs


    As I was working on the Calendar Page Maker powertoy for OneNote, I hit a problem at one point with trying to get the size of the columns in the table correct.  I wanted my table to look like this:


    Time of Day

    A really wide column to hold the events


    Hopefully, you can see the width of the column on the right is much wider than the one on the left.  But before 

    I started with a table which looked like this to get the XML:




    Here's what I wound up with using OMSpy.



                <one:Column index="0" width="37.11000061035156" />

                <one:Column index="1" width="37.11000061035156" />



    Since I wanted the right most column to be much wider, I added code to create this XML:


                <one:Column index="0" width="50" />

                <one:Column index="1" width="350/>



    After running the code, I wound up with the "small" table again:




    Hmm.  Obviously, I was overlooking something.  I manually resized the right column and then double checked the XML :


                <one:Column index="0" width="37.11000061035156" />

                <one:Column index="1" width="381.5100402832031" isLocked="true" />


    I did not know what that "isLocked" attribute was, so I did what I should have done before starting and checked the schema reference Microsoft has online.  Here's the relevant text from the file if you don't want to download the schema help for Office 2007:


    The "isLocked" attribute

    By default the widths of columns are unlocked and can be resized as the user types content into a cell. Once the user [h]as sized or resized a column width this attribute is set to true.


    So my original version of the powertoy had omitted this attribute.  Adding that attribute would mimic the behavior of a user manually altering the column size, so I changed my code to this:


                table += "<one:Column index=\"0\" width=\"50\" />";

                table += "<one:Column index=\"1\" width=\"350\" isLocked=\"true\" />";//just guessing for decent screen resolution


    The next time I created an agenda page, the column showed as the correct width.  Mentally, I resolved the bug as fixed and now keep a copy of the schema to go hand in hand with the XML I see using OMSpy.  This shows a difference between valid XML and XML that behaves the way you want it to do.  The isLocked attribute is optional, so my original code worked.  That attribute is needed to override the default column size OneNote wants to use. 


    Questions, comments, concerns and criticisms are always welcome,











Comments (1)

  1. Once I made my change to my calendar/planner addin to get the columns to size correctly , I needed to

Skip to main content