+ Reply to Thread
Results 1 to 9 of 9

Possible for VBA to to OCR embedded picture objects and copy text values to cells?

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2003
    Posts
    8

    Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    Thanks in advance to anyone who can help me with this. This is cross-posted without any responses as of the time of this post, at:

    https://www.mrexcel.com/forum/excel-...ues-cells.html

    My Excel 2013 worksheet has several embedded pictures of numerical values that have been obtained from a PrtSc of another application. Using VBA, the images are then pasted from the clipboard, named, and cropped to include only a single number with decimal point (ex: 123.4). I'd like to go a step further and have their values automatically pasted into cells. But without a method of OCR, I have to manually type the values into the target cells in order to perform further calculations from which they are based.

    Is it possible to OCR these named picture objects, such as via MODI or OneNote? My workbook is intended for distribution and use on a secure network, so installation of a 3rd party OCR application may not be possible.

    I've tried to do my part to figure this out by an extensive Google search and am led to conclude that nobody has posted a solution to the specific concept I'm after.

    Everything I gather about OneNote is that I could use VBA to execute the application but cannot continue with VBA to perform the OCR and transport the results back to Excel. Please correct me if I'm wrong.

    Microsoft has made MODI available again, so I installed it and have added a VBA Reference to the "MODI 12.0 Type Library". My attempts at reverse engineering MODI-specific VBA commands I've found on the web have either done nothing, given errors, or crashed Excel.

    So, my thought is this concept just isn't possible, but please only confirm this if you know for sure. Otherwise, any solutions or resources are greatly appreciated.
    Last edited by jasonfromchico; 07-22-2017 at 01:10 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    It looks as though you should be able to achieve this
    Manually I
    - created a jpeg,
    - pasted that into Excel,
    - copied it to OneNote , -
    - selected "Copy Text From Picture" and
    - pasted the text into Excel

    The VBA must be resident in Excel - OneNote supports VBA but does not have its own VBA container!
    In principle, it should be merely a matter of adding the references to OneNote and writing some fairly simple code, but I cannot immediately find the elements that are required!
    I will have some time (in some 10 days or so) to investigate and will let you know how I get on.

    If I do get there, I need to know a little more:
    - are your files jpegs?
    - how are they tagged to cells (need to know where to place the text)

    Do you want to
    - loop through each jpeg(?) on a sheet
    - paste it to OneNote
    - copy text from picture
    - paste the text back into the cell each image is tagged to?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    03-21-2014
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    kev_,

    Thanks for the info. My images are not files, so I don't know if there is a file-type. Rather, they are pasted directly into Excel from a screenshot. I don't know if they are tagged to certain cells, as that's not something I've ever done. I have them located in a certain area but for all intents and purposes they are free floating.

    My image is obtained by pressing the PrtSc button while in another software window. Following this, I return to Excel and a macro pastes the screenshot, crops it down to a single numerical value (that is always in a specific region of the screenshot), and names the pasted/cropped picture object of this numerical value. VBA then compresses the picture object and deletes the parts of the screenshot that were cropped away. At this point, I am wanting VBA to OCR the numerical value and paste it into a target cell for use in calculations.
    Last edited by jasonfromchico; 07-22-2017 at 08:18 AM.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    Ok
    VBA already has a handle on the picture - it's already doing something with it
    So how will we tell VBA what the target cell reference should be? - user to input when image is processed?

  5. #5
    Registered User
    Join Date
    03-21-2014
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    kev_,

    Each image I'm needing to OCR will have a unique identifier via code Selection.Name that is associated with a unique target cell. Below is a sample of my code to illustrate:

    Please Login or Register  to view this content.
    Last edited by jasonfromchico; 07-23-2017 at 07:25 AM.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    Please click Edit Post on Post#5, select the VBA code text, then click on # icon above - this puts your code in code tags - thanks

    My stumbling point is creating a line of code that will do the "Copy Text From Picture" bit
    - sounds simple enough doesn't it!


    Have you spotted these two links:
    Programmatically inserting image into Onenote page using VBA from Access 2010
    OneNote is not giving OCRText for (VBA) inserted image in OneNote 2010.How to force onenote to do OCR on Image?
    - 2nd one still awaiting input of Senior Engineers since June 2013...
    Last edited by kev_; 07-23-2017 at 01:49 AM.

  7. #7
    Registered User
    Join Date
    03-21-2014
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    kev_,

    I have not seen those particular links, but have found a couple other failed attempts at performing OCR using XML. I have absolutely no knowledge on XML or how it ties into MS Office applications. Is it an alternative language that's necessary in some circumstances?

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    I,too, lack any knowledge on XML
    I'm hoping that I can find a VBA solution - but available documentation is very thin.....

  9. #9
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Possible for VBA to to OCR embedded picture objects and copy text values to cells?

    My ressearch suggests that you probably need to follow:
    this route
    to make life easy with OneNote!
    Last edited by kev_; 07-23-2017 at 09:24 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Modify VBA to insert picture embedded in file instead of a link to a picture
    By edthedrummer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-25-2017, 02:12 AM
  2. Viewing the text of a cell through an embedded jpg picture
    By Richard Buttrey in forum Excel General
    Replies: 19
    Last Post: 04-16-2016, 05:43 PM
  3. Replies: 3
    Last Post: 01-13-2012, 12:11 PM
  4. Embedded Objects on Userform
    By vincentus84 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2009, 07:32 AM
  5. Embedded objects
    By Mike25 in forum Excel General
    Replies: 1
    Last Post: 03-23-2006, 10:10 AM
  6. Embedded Objects
    By Lightfoot in forum Excel General
    Replies: 0
    Last Post: 12-30-2005, 10:25 AM
  7. Copying Embedded Objects
    By jmoseley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2005, 03:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1