+ Reply to Thread
Results 1 to 3 of 3

Import Images/Pictures/Shapes from a Closed Excel Workbook

  1. #1
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Import Images/Pictures/Shapes from a Closed Excel Workbook

    I have a Closed Excel workbook in which there are pictures inserted in a sheet.

    I want to import these pictures or Shapes from this CLOSED temporary workbook into my current Workbook.
    • Does ADO have a method to write an SQL Query to import Images/Pictures/Shapes embedded in an Excel Sheet without opening the Excel Workbook?
    • Any alternative methods to import the Images/Pictures/Shapes?
    • Can ADODB.STREAM object pull all the images from the Sheet of the Closed Excel Workbook as HEX or BLOB data and store them in a Collection Class or Dictionary Class for later use?
    • Can an MSMXML2.Document object be able to read the Sheet (.Load File OR .LoadXML Range.Value() ) of a the Closed Excel Workbook and have information of the Images/Pictures/Shapes in its XML, that can be processed further to recreate the images into the Current Workbook?

    Any help will be most appreciated.

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Import Images/Pictures/Shapes from a Closed Excel Workbook

    Couple thoughts:
    1. Unless you absolutely cant, the typical approach to this is for VBA to open the file, act on it, close it when done. This can be done so the file is never visible on the screen. It can also be done "safely" by opening the file read-only so its not saved over by the macro when closing it.
    2. If opening the file is not an option, you can create a copy of the file, change the extension to .zip (assuming its xlsx or xlsm), extract the contents and extract the images as files out of the underlying parts of the file and then trash the extracted out copied file after getting what you need. The issue with this approach is that your just getting 1 file per image regardless of if the same image was in the file in different places multiple times. You also cannot easily identify what sheet a given image was on.
    3. As an expansion on the above, you could use something like XML DOM (MSMXML2) and XML nodes/tags to discover the XML that depicts placement of the images AND also pull the needed files from the copied original file (extracted out from zip) so that your file actually contains the images the updated XML tags/code refers to.

    Ideally, my recommendation for the easiest, simplest solution is to have your code open the file, copy the images over, close the file.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Contributor
    Join Date
    03-07-2006
    Location
    India
    MS-Off Ver
    MSOffice 365 Professional 64 bit
    Posts
    108

    Re: Import Images/Pictures/Shapes from a Closed Excel Workbook

    Thanks for your kind reply.

    Your idea of zipping the closed temp.xlsx workbook and extracting the images using XMLDOM and XML nodes sounds interesting. Is there an example available for this excel zipping and extracting images from zip?

    Just a random thought:
    • Is there a way to hold the pictures in memory (maybe as a BLOB or a Picture itself) using some Custom Class (Dictionary or Collection Class) till the workbook (session) is open, and then, whenever needed, use them (convert them back from BLOB to picture) for inserting into a worksheet cells of current workbook for report creation? If so, how can such a Custom Class be created?
    • Long ago, I had seen somewhere an example of someone converting a bunch of images pulled from a folder into HEX data, storing them into a Custom Array Class (to maintain live session) and then reconverting the HEX data back to individual images to be inserted into worksheets, whenever required. Unfortunately, i was unable to locate this code anymore.

+ 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] VBA code protect images/pictures on Excel sheet
    By bjnockle in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2016, 08:16 AM
  2. Inserting Shapes and Pictures in a protected workbook
    By ExcelCMMguy in forum Excel General
    Replies: 4
    Last Post: 04-08-2016, 08:01 AM
  3. Excel VBA to save PPT shapes as PNG images
    By Robert Goddard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2014, 04:39 AM
  4. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  5. locking shapes and pictures on excel sheet
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2013, 09:50 PM
  6. Import all sheets from closed workbook to the open workbook
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2013, 04:05 AM
  7. Replies: 1
    Last Post: 11-26-2011, 09:10 PM

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