none
OneNote - Change hyperlink addresses with VBA RRS feed

  • Question

  • Can someone help please?

    I have hundreds of files in a folder called c:\Data and I use hyperlinks to access them from Onenote 2010. I’d like to move the files to my d drive into a folder called d:\OneNoteData

    Is there a way that I can update all my hyperlinks in OneNote using VBA to save me having to update them all manually? If not VBA can I use any other language?

     

    Thanks

    Friday, September 30, 2011 3:58 PM

Answers

  • VBA does not work with OneNote, so you're going to have to use OneNote's COM API.

    Take a look at the OneNote 2010 Developer Reference or the MSDN magazine article on OneNote's Object Model.

     

    Probably something along the lines of:

    1. Using GetHierarchy() to get all the pages in your particular section / notebook / all notebooks
    2. Extracting the pageId's from the resultant XML document

      1. Using GetPageContent() to get the content of that page
      2. Look for <a href="file:///C:\Data\" ... /> in <one:T ... /> (text) elements on the page
      3. Replace each link with <a href="file:///D:\OneNoteData\" ... />
      4. Use UpdatePageContent() to apply the changes you made

    3. Repeat for every page.


    • Edited by Malte Ahrens Sunday, October 2, 2011 9:58 AM
    • Marked as answer by Bruce Song Tuesday, October 11, 2011 3:38 AM
    Sunday, October 2, 2011 9:53 AM

All replies

  • VBA does not work with OneNote, so you're going to have to use OneNote's COM API.

    Take a look at the OneNote 2010 Developer Reference or the MSDN magazine article on OneNote's Object Model.

     

    Probably something along the lines of:

    1. Using GetHierarchy() to get all the pages in your particular section / notebook / all notebooks
    2. Extracting the pageId's from the resultant XML document

      1. Using GetPageContent() to get the content of that page
      2. Look for <a href="file:///C:\Data\" ... /> in <one:T ... /> (text) elements on the page
      3. Replace each link with <a href="file:///D:\OneNoteData\" ... />
      4. Use UpdatePageContent() to apply the changes you made

    3. Repeat for every page.


    • Edited by Malte Ahrens Sunday, October 2, 2011 9:58 AM
    • Marked as answer by Bruce Song Tuesday, October 11, 2011 3:38 AM
    Sunday, October 2, 2011 9:53 AM
  • Malte,

    Thanks for your reply.  sorry for not getting back to you sooner.  I working away from the office just now and have not had a chance to try what you suggest.  I'll get back to you.

     

    Thanks 

    Thursday, October 13, 2011 5:28 AM
  • Hello Supertension,

    did it work? If yes, could you send the code? Thank you in advance.

    Wednesday, March 14, 2012 12:58 PM