2012-03-14 1 views
0

OneNote 2010에서 전자 필기장을 추가하는 방법을 알아 내려고합니다. 새 전자 필기장을 추가하기 위해 UpdateHiearchy API를 사용하는 방법을 보여주는 코드 샘플을 찾을 수 없습니다. VB6 응용 프로그램에서이 작업을 수행하려고합니다. 나는 VB에서 XML을 사용하는 것에 익숙하지 않다.OneNote에서 전자 필기장을 만들기 위해 VB 코드에서 UpdateHiearchy를 사용합니다.

Private Function GetFirstOneNoteNotebookNodes(oneNote As OneNote14.Application) As MSXML2.IXMLDOMNodeList 
    ' Get the XML that represents the OneNote notebooks available. 
    Dim notebookXml As String 
    ' OneNote fills notebookXml with an XML document providing information 
    ' about what OneNote notebooks are available. 
    ' You want all the data and thus are providing an empty string 
    ' for the bstrStartNodeID parameter. 
    oneNote.GetHierarchy "", hsNotebooks, notebookXml, xs2010 

    ' Use the MSXML Library to parse the XML. 
    Dim doc As MSXML2.DOMDocument 
    Set doc = New MSXML2.DOMDocument 

    Dim elem As MSXML2.IXMLDOMElement 

    If doc.loadXML(notebookXml) Then 
     ' Here is search for a notebook that i know is not there.  mvarpAssignment.pClient.Name is a program variable that contains a text name. 
     Set GetFirstOneNoteNotebookNodes = doc.documentElement.selectNodes("//one:Notebook[@name='" & mvarpAssignment.pClient.Name & "']") 
' I test the length for zero to see if anything was returned:   
If GetFirstOneNoteNotebookNodes.Length = 0 Then 
' I want to create a notebook, so i beleive i need to add an element to the xml returned from the GetHiearchy API:   
Set elem = doc.createElement("ROC") 
      doc.documentElement.appendChild elem 
'I print out the xml and i can see the element added at the end of the xml document.    
      Debug.Print doc.XML 

'다음 단계는 UpdateHiearchy API를 호출하는 것입니다하지만 whch 내가 API에 전달할 객체로서 내가 손해를보고 나는 다음과 같이 코드입니다. 내가 시도하는 모든 것은 실패합니다. 분명히 충분히 이해가 안되지만 나는 노트북을 추가하는 방법을 설명하는 코드 샘플이나 텍스트를 찾을 수 없습니다. 도움이나 infomation에 대한 링크가 크게 감사하겠습니다!

답변

0

나는 마침내이 작업을했습니다. 두 가지가 잘못되었습니다. 계층 구조를 업데이트하기 전에 경로를 정의해야합니다. GetSpecialLocation API를 사용해야합니다. 또한 애트리뷰트 이름은 감각적 인 것으로, 소문자보다는 낙타의 경우가 있습니다. 나는 원래 코드에서 다른 변경 사항들을 만들어 냈지만, 내 애플리케이션에 대해서는 tismore라고했다. 관심있는 사람들을위한 수정 된 코드 :

Private Function GetClientOneNoteNotebookNode(oneNote As OneNote14.Application,  ClientName As String) As MSXML2.IXMLDOMNodeList 
Dim notebookXml As String 
Dim doc As MSXML2.DOMDocument 
Dim elem As MSXML2.IXMLDOMElement 
Dim newNotebookPath As String 
Dim defaultNotebookFolder As String 
' OneNote fills notebookXml with an XML document providing information 
' about what OneNote notebooks are available. 
' You want all the data and thus are providing an empty string 
' for the bstrStartNodeID parameter. 
oneNote.GetHierarchy "", hsNotebooks, notebookXml, xs2010 
' Use the MSXML Library to parse the XML. 
Set doc = New MSXML2.DOMDocument 
If doc.loadXML(notebookXml) Then 
Set GetClientOneNoteNotebookNode = doc.documentElement.selectNodes("//one:Notebook[@name='" & ClientName & "']") 
If GetClientOneNoteNotebookNode.Length = 0 Then 
'Get the default location for the notebooks 
oneNote.GetSpecialLocation slDefaultNotebookFolder, defaultNotebookFolder 
newNotebookPath = defaultNotebookFolder + "\\" + ClientName 
'Create new notebook for cleint 
Set elem = doc.createElement("one:Notebook") 
elem.setAttribute "name", ClientName 
elem.setAttribute "path", newNotebookPath 
' add new elelement to the document tree 
doc.documentElement.appendChild elem 
oneNote.UpdateHierarchy doc.XML 
End If 
Else 
Set GetClientOneNoteNotebookNode = Nothing 
End If 
End Function 
관련 문제