ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy image from existing workbook / template (https://www.excelbanter.com/excel-programming/385237-copy-image-existing-workbook-template.html)

Dan Kelly

Copy image from existing workbook / template
 
We've just discovered a bug depending on whether Macro A or Macro has been
run on a workbook.

Macro A inserts an image from an original jpg on a network drive

Macro B inserts an image from an exisiting "template" in the workbook.

Whilst both images are the same (the image pasted in the template came from
the original jpg) the first Macro causes us problems when run a third macro
which reformats the workbook. If the source of the images on the workbook is
Macro A they get duplicated.

We want to rewrite the Macro to insert the images from a network copy of the
excel template - ideally without opening it.

Any suggestions?

Tom Ogilvy

Copy image from existing workbook / template
 
I don't think you can grab an image from a closed workbook using existing VBA
properties and methods. Perhaps if you wrote code that can read the raw
compound document format and perhaps the BIFF format and extract and
interpret the sequence of bytes in the document that make up the image, you
could do that, but that would require many many lines of code and thorough
understanding of how the information is stored and how the data for an image
should be interpreted.

--
Regards,
Tom Ogilvy


"Dan Kelly" wrote:

We've just discovered a bug depending on whether Macro A or Macro has been
run on a workbook.

Macro A inserts an image from an original jpg on a network drive

Macro B inserts an image from an exisiting "template" in the workbook.

Whilst both images are the same (the image pasted in the template came from
the original jpg) the first Macro causes us problems when run a third macro
which reformats the workbook. If the source of the images on the workbook is
Macro A they get duplicated.

We want to rewrite the Macro to insert the images from a network copy of the
excel template - ideally without opening it.

Any suggestions?


Dan Kelly

Copy image from existing workbook / template
 
In that case, is there any way I can "hide" the fact that I am opening up the
template in order to copy the image on it?

"Tom Ogilvy" wrote:

I don't think you can grab an image from a closed workbook using existing VBA
properties and methods. Perhaps if you wrote code that can read the raw
compound document format and perhaps the BIFF format and extract and
interpret the sequence of bytes in the document that make up the image, you
could do that, but that would require many many lines of code and thorough
understanding of how the information is stored and how the data for an image
should be interpreted.

--
Regards,
Tom Ogilvy


"Dan Kelly" wrote:

We've just discovered a bug depending on whether Macro A or Macro has been
run on a workbook.

Macro A inserts an image from an original jpg on a network drive

Macro B inserts an image from an exisiting "template" in the workbook.

Whilst both images are the same (the image pasted in the template came from
the original jpg) the first Macro causes us problems when run a third macro
which reformats the workbook. If the source of the images on the workbook is
Macro A they get duplicated.

We want to rewrite the Macro to insert the images from a network copy of the
excel template - ideally without opening it.

Any suggestions?



All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com