none
How to make it work for all OneNote versions? RRS feed

  • Question

  • Hi,

    In my previous post (http://social.msdn.microsoft.com/Forums/en-US/1a312686-1e1f-45c0-b754-56e98e3af94f/how-to-create-a-new-onenote-notebook-using-vbnet?forum=officegeneral&prof=required), I was able to create a page and update it in OneNote 2013. Now, I need to have this one working for as well as the current (2013) and previous versions of OneNote (2007 and 2010).

    The related COM reference for Microsoft Office OneNote 2013 is already present in the project.

    With kind regards,

    Roland


    Running a: virt. WIN8 and VS Ultimate 2012 - Visual Basic ... Hosted in: MS Windows Server 2012 Std on Acer Aspire 5750 ... Intel Core i5-2430M 2.4GHz - 16 GB DDR3 memory - 1 TB HDD

    Tuesday, August 19, 2014 1:38 PM

Answers

  • Hi Roland,

    I assume you are using VB.NET.

    >> I just want to know if the Microsoft OneNote 15.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000 is backwards compatible or not.

    Currently, I’m not able to find a detail document to answer this question.

    But I did some research about the Interop Libs of OneNote Interop 12.0, 14.0 and 15.0. Here is result for your reference.

    IIDs:

    15.0: D7FAC39E-7FF1-49AA-98CF-A1DDD316337E

    14.0: D7FAC39E-7FF1-49AA-98CF-A1DDD316337E

    12.0: 0039FFEC-A022-4232-8274-6B34787BFC27

    As we can see from the IIDs, The 14.0 version and 15.0 version have the same IID, so technically, the Interop of 14.0 and 15.0 are compatible, but the 12.0 Interop is not compatible with 14.0 and 15.0.

    There are new enumerations introduced by OneNote 2013 Interop (see Enumerations OneNote 2013 Developer Reference), and you cannot use these new features in OneNote 2010.  If your add-in referenced the OneNote Interop 15.0 and use it in OneNote 2010, an assembly dependency error will occur; in contrast, if your add-in reference the OneNote Interop 14.0 and use it in OneNote 2013, it will work fine. My current work around is reference the OneNote Interop 15.0 and change the “Embed Interop Types” property to “False”, “Copy Local” property to “True”. I have not tested the side effects yet, it should make you being able to use “OneNote Interop 15.0” to operate OneNote 2010, but you need to avoid using new features in OneNote 2013 when using your add-in OneNote 2010.

    Hope it will help.

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 28, 2014 5:54 AM
    Moderator

All replies

  • You need to change the reference if you want to support older OneNote versions. Keep the reference to the oldest version if you want to get them working correctly. If you need to call any specific API which is absent in the interop file you have included (corresponds to the COM reference version) you may use the late binding technology for calling such API dynamically (see Type.InvokeMember). Don't forget to check the OneNote version to make sure that such API is presented.
    Tuesday, August 19, 2014 4:47 PM
  • Hi,

    Thank you for your fast reply. So, if I understand you correctly:

    The currently installed Microsoft OneNote 15.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000 needs to be changed to Microsoft OneNote 12.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000

    I have done that, but many of the parameters are not known with this library. Also, I thought to believe that the OneNote 15.0 Type Library was backwards compatible. I have yet to test this out, but I think this could work with Microsoft OneNote 15.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000 installed.

            Dim strEVersionSubKey As String = "\OneNote.Application\CurVer" '/HKEY_CLASSES_ROOT/OneNote.Application/Curver
            Dim strValue As String 'Value Present In Above Key
            Dim rkVersion As RegistryKey = Nothing 'Registry Key To Determine OneNote Version
    
            rkVersion = Registry.ClassesRoot.OpenSubKey(name:=strEVersionSubKey, writable:=False) 'Open Registry Key
    
            Dim oneNote As OneNote.Application
            oneNote = New OneNote.Application
    
            ' Get all of the Notebook nodes. 
            Dim nodes As MSXML2.IXMLDOMNodeList
            nodes = GetFirstOneNoteNotebookNodes(oneNote)
            If Not nodes Is Nothing Then
                ' Get the first OneNote Notebook in the XML document. 
                Dim node As MSXML2.IXMLDOMNode
                node = nodes(0)
                Dim noteBookName As String
                noteBookName = node.attributes.getNamedItem("name").text
    
                ' Get the ID for the Notebook so the code can retrieve 
                ' the list of sections. 
                Dim notebookID As String
                notebookID = node.attributes.getNamedItem("ID").text
    
                ' Load the XML for the Sections for the Notebook requested. 
                Dim sectionsXml As String
                'oneNote.GetHierarchy(notebookID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, sectionsXml)
    
                If Not rkVersion Is Nothing Then 'If Key Exists
                    strValue = rkVersion.GetValue(String.Empty) 'get Value
                    strValue = strValue.Substring(strValue.LastIndexOf(".") + 1) 'Store Value
    
                    Select Case strValue 'Determine Version
                        Case "12" 'Microsoft Office OneNote 2007
                            oneNote.GetHierarchy(notebookID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, sectionsXml, Microsoft.Office.Interop.OneNote.XMLSchema.xs2007)
                        Case "14" 'Microsoft Office OneNote 2010
                            oneNote.GetHierarchy(notebookID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, sectionsXml, Microsoft.Office.Interop.OneNote.XMLSchema.xs2010)
                        Case "15" 'Microsoft Office OneNote 2013
                            oneNote.GetHierarchy(notebookID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, sectionsXml, Microsoft.Office.Interop.OneNote.XMLSchema.xs2013)
                        Case Else
                            oneNote.GetHierarchy(notebookID, Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections, sectionsXml)
                    End Select
                End If

    In the Select Case statement, I want to check which version is installed and use that version. Could this work?

    With kind regards,

    Roland


    Running a: virt. WIN8 and VS Ultimate 2012 - Visual Basic ... Hosted in: MS Windows Server 2012 Std on Acer Aspire 5750 ... Intel Core i5-2430M 2.4GHz - 16 GB DDR3 memory - 1 TB HDD

    Wednesday, August 20, 2014 7:39 AM
  • Hi,

    Forget about the source code provided. I just want to know if the Microsoft OneNote 15.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000 is backwards compatible or not. Will it be able to work with the previous versions of OneNote? Can someone please provide me with an answer?

    Based on the following page: Enumerations (OneNote 2013 Developer Reference) - XMLSchema (updated for OneNote 2013)

    With kind regards,

    Roland


    Running a: virt. WIN8 and VS Ultimate 2012 - Visual Basic ... Hosted in: MS Windows Server 2012 Std on Acer Aspire 5750 ... Intel Core i5-2430M 2.4GHz - 16 GB DDR3 memory - 1 TB HDD

    Monday, August 25, 2014 7:58 AM
  • Hi Roland,

    Why do you need to use a type library if you develop a managed application? May be you are talking about interop files?

    Typically, the latest interop library can be used for automating older versions until you call methods or properties available only in the latest version. So, the interop contains the definition and knows how to marshal your call. But the host application (older versions) don't know anything about that. In such cases you need to check at runtime the host version and make a call to the new members or not (may be implement a workaround).

    From the opposite side of view, you can use the earlier version of interop files that contain all properties and methods available in the min supported version. But when you need to call the new members you may use the Type.InvokeMember method to call them dynamically.

    Monday, August 25, 2014 3:12 PM
  • Hi, The reason why is, that I followed the guidelines in this article: http://code.msdn.microsoft.com/office/OneNote-2010-Create-New-880f8ee3 Here is referred to the object component. Kind regards, Roland

    Running a: virt. WIN8 and VS Ultimate 2012 - Visual Basic ... Hosted in: MS Windows Server 2012 Std on Acer Aspire 5750 ... Intel Core i5-2430M 2.4GHz - 16 GB DDR3 memory - 1 TB HDD

    Monday, August 25, 2014 4:14 PM
  • Hi Roland,

    I assume you are using VB.NET.

    >> I just want to know if the Microsoft OneNote 15.0 Type Library (COM Type Libraries) - File version 15.0.4599.1000 is backwards compatible or not.

    Currently, I’m not able to find a detail document to answer this question.

    But I did some research about the Interop Libs of OneNote Interop 12.0, 14.0 and 15.0. Here is result for your reference.

    IIDs:

    15.0: D7FAC39E-7FF1-49AA-98CF-A1DDD316337E

    14.0: D7FAC39E-7FF1-49AA-98CF-A1DDD316337E

    12.0: 0039FFEC-A022-4232-8274-6B34787BFC27

    As we can see from the IIDs, The 14.0 version and 15.0 version have the same IID, so technically, the Interop of 14.0 and 15.0 are compatible, but the 12.0 Interop is not compatible with 14.0 and 15.0.

    There are new enumerations introduced by OneNote 2013 Interop (see Enumerations OneNote 2013 Developer Reference), and you cannot use these new features in OneNote 2010.  If your add-in referenced the OneNote Interop 15.0 and use it in OneNote 2010, an assembly dependency error will occur; in contrast, if your add-in reference the OneNote Interop 14.0 and use it in OneNote 2013, it will work fine. My current work around is reference the OneNote Interop 15.0 and change the “Embed Interop Types” property to “False”, “Copy Local” property to “True”. I have not tested the side effects yet, it should make you being able to use “OneNote Interop 15.0” to operate OneNote 2010, but you need to avoid using new features in OneNote 2013 when using your add-in OneNote 2010.

    Hope it will help.

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 28, 2014 5:54 AM
    Moderator
  • Hi,

    I am sorry, I made an typo there. I am not using the Microsoft OneNote 15.0 Type Library, but the Microsoft OneNote 15.0 Object Library - v1.1.0.0 (COM type). Copy Local is set on: True and Embed Interop Types is set on: False.

    In my source code, I am not using the XMLSchema. By doing so I honored the note, quoted here:

    "We recommend specifying a version of OneNote (such as xs2013) instead of using xsCurrent or leaving it blank, because this will allow your add-in to work with future versions of OneNote."

    Although, I am using the piAll from the PageInfo (GetPageContent method) and again, without using the XMLSchema). I have changed this now to piBasic and I am about to test this with OneNote 2010.

    In any case, I thank you for this clear explaination. This makes sense now. I will let you know what the outcome is.

    With Regards,

    Roland


    Running a: virt. WIN8 and VS Ultimate 2012 - Visual Basic ... Hosted in: MS Windows Server 2012 Std on Acer Aspire 5750 ... Intel Core i5-2430M 2.4GHz - 16 GB DDR3 memory - 1 TB HDD


    • Edited by RoBeDi Thursday, August 28, 2014 7:27 AM Changed note
    Thursday, August 28, 2014 7:25 AM