Share via

How to use VBA for OCR function with OneNote

Anonymous
2012-11-20T08:58:52+00:00

I have full suit of office and Adobe Reader/Acrobat. 

I need to take actions as below:

  1. Open PDF file9(s).
  2. Copy the images from PDF to OneNote file.
  3. OCR the images.
  4. Get keywords from the texts.

All the steps should be processed by VBA.

Microsoft 365 and Office | OneNote | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2015-04-13T08:30:07+00:00

    In Excel or Word you are able to use OLE Automation with the Object Library for

    OneNote 2010.

    In the following Link you find an Article as a starting Point!

    https://code.msdn.microsoft.com/office/onenote-2010-retrieve-data-023e69c0

    Hier are some Information what you will expect.

    Building the Sample

    Use any VBA host including Excel 2010, PowerPoint 2010, or Word 2010. OneNote 2010 is not a VBA host.

    In your VBA host, add references to the following external libraries using the Add References dialog:

     - Microsoft OneNote 14.0 Object Library

     - Microsoft XML, v6.0

    OneNote's GetHierarchy method allows you to get meta-data and data about the OneNote Notebooks.

    Paste all this code into a module, place the cursor within the ListOneNoteNotebooks procedure, and press F5.

    But the Problem is how to find the OneNote14 Type Library?

    Even on PC's with the Office 2010 installed I did not find it!?

    Sub ListOneNoteNotebooks() 

        ' Connect to OneNote 2010. 

        ' OneNote will be started if it's not running. 

        Dim oneNote As OneNote14.Application 

        Set oneNote = New OneNote14.Application 

        ...

    5 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2013-01-16T15:54:14+00:00

    AFAIK Onenote doesn't support macros or VBA.

    Onenote does support VBA, but you cannot write or access VBA from within OneNote.  It instead has to be written and run from a "Host" application such as Excel, Word, or PowerPoint.  I had been looking into doing the same thing when I stumbled on your thread, but unfortunately hadn't gotten any further than basic note creation. 

    MSDN has a good primer on OneNote VBA programming but I haven't seen many resources for more advanced topics.

    http://msdn.microsoft.com/en-us/library/hh377183(v=office.14).aspx

    5 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2012-11-21T04:31:52+00:00

    VBA/Macros????

    AFAIK Onenote doesn't support macros or VBA.

    5 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2015-12-09T06:04:12+00:00

    Thanks - this set me on the right track for a recent similar requirement to OPs.

    For my requirement at least (scanning an 'ID' type card and capturing key data) I found that OneNote OCR works *far* better with jpg files than it does with pdf files. Although all scanner settings were the same (except for FileType) and I turned off OCR on the scanner itself, the OCR on PDF files was very poor but quite usable (for our purposes) on jpg files.

    2 people found this answer helpful.
    0 comments No comments
  5. Anonymous
    2013-01-16T17:16:55+00:00

    You can try:

    1. ShellExecute with print command for the PDF to insert the PDF as a printout to OneNote, you need Send to OneNote as default printer. Alternatively if you can convert the PDF into images by some third party library, you can then insert those images into OneNote using Application.UpdatePageContent (See http://msdn.microsoft.com/en-us/library/office/jj680120.aspx).

    1. Use Application.Windows.CurrentWindow.CurrentPageId to get the id of the current page (See http://msdn.microsoft.com/en-us/library/office/jj680123.aspx)
    2. Use Application.GetPageContent to read the page content which will include the OCR info (See http://msdn.microsoft.com/en-us/library/office/jj680120.aspx).

    You can't force OCR to run, OneNote will run it shortly, but may not be done by the time you ask for page content. If you want to execute this from inside OneNote, you need to write a COM add-in. Otherwise see Volkl's reply for running VBA inside another host (e.g. Excel).

    2 people found this answer helpful.
    0 comments No comments