+ Reply to Thread
Results 1 to 8 of 8

Text to Image?!

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Talking Text to Image?!

    This is an unusual request. :D

    Yes, it is text-to-image, not image-to-text/OCR.

    Supposing I have a lot of text-type files. I am curious if it would be possible to create a VBA function that will create images that would display the text contents?
    • Input = Your choice of any type of file that has text content. (e.g. .txt, .json, .xml, .ini, .cfg etcetcera)
    • Output = Your choice of any of the following formats: .png, .jpeg, .bmp
    • Other requirements = Function will not require any external software. (Windows APIs and Excel reference libraries are OK)

    To clarify "Your choice" in above - This means that I don't care which input/output formats you decide upon out of the above. Once I have a working function (assuming this is doable) I can modify it to suit my requirements.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,550

    Re: Text to Image?!

    .
    If you can load your text into an Excel sheet, this macro will save it as a .JPG to the desktop :

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Text to Image?!

    Quote Originally Posted by Logit View Post
    .
    If you can load your text into an Excel sheet, this macro will save it as a .JPG...[snip]
    :slaps forehead: of course! I even wrote a module about a year ago to capture part of an excel sheet to an image for end user approval (That probably sounds stupid - why not just show the excel sheet? - Because it was in a separate workbook to the Excel system that displayed the image)

    I just didn't think to apply that logic to this scenario. Thanks for reminding me Logit - reps.

    This method (text -> worksheet -> image) would work but it would be slow. I would be interested if there are any alternative options that would be faster.

    (I am guessing it would be all but impossible to push the text into an image in memory as a byte array? Because each character would need to be represented as a set of bytes that would make up the pixels for that character - reverse OCR if you will)

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,550

    Re: Text to Image?!

    .
    I'm not aware if the process can be made faster.

    It goes without saying that the macro provided would be just one portion of the workbook. You would create other macro/s that will provide the use of a FileDialog control for locating
    the TEXT file to be converted. Or if the TEXT file is the same with new data each time, simply access that file then copy the range/s desired and paste to the Excel Sheet, then automate the process of converting to an image.

    The above process will take a second or so ... not sure how you could make it faster.

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Text to Image?!

    Quote Originally Posted by Logit View Post
    .It goes without saying that the macro provided would be just one portion of the workbook. You would create other macro/s that will provide the use of a FileDialog control for locating
    the TEXT file to be converted. Or if the TEXT file is the same with new data each time, simply access that file then copy the range/s desired and paste to the Excel Sheet, then automate the process of converting to an image.
    No problem. That part is already in place (I usually frame my threads around only the portion I am having trouble with rather than entire project)

    Quote Originally Posted by Logit View Post
    The above process will take a second or so ...
    Probably. But the 2-3 seconds in my case would need to be multiplied by (potentially) several thousand files! (I just love writing code to save myself time by processing large batches )


    Quote Originally Posted by Logit View Post
    not sure how you could make it faster.
    Same. (Well apart from my reverse OCR idea! lol)

    So I will close the thread.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,230

    Re: Text to Image?!

    I'd suspect that using APIs like Stephen Bullen's PastePicture module would be faster than creating charts and exporting.
    Rory

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Text to Image?!

    Quote Originally Posted by rorya View Post
    I'd suspect that using APIs like Stephen Bullen's PastePicture module would be faster than creating charts and exporting.
    Most likely. But where do I find this?

    I had bought Stephen Bullen's (and Bovey and Wallentin and Green) book 'Professional Excel Development Second Edition' - Is the code somewhere in there? I couldn't find it in the index.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,230

    Re: Text to Image?!

    Google....

+ 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] Hyperlink text to image
    By didierkassas in forum Excel General
    Replies: 20
    Last Post: 07-19-2018, 04:51 AM
  2. Inserting image into userform label, text behind image?!?!
    By spyrule in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 08-31-2016, 03:23 PM
  3. Macro to automatically convert prt scr image-based text to real text in cell
    By jasonfromchico in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 02:27 PM
  4. VBA: Put text from excel to jpeg image by matching image name.
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 01:47 AM
  5. Substitute text for an image.
    By benyates1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2009, 03:04 AM
  6. Move Image Behind Text?
    By Accendo in forum Excel General
    Replies: 1
    Last Post: 02-23-2008, 11:53 AM
  7. How to put the image under the text
    By Jimmy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2005, 09:05 AM

Tags for this Thread

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