×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

(OP)
After poking the bear and touring the internet I finally understand why people always said storing pictures in Access is bad, it is because they are invariably put in by bound controls or directly into the tables via native Access UI which means an entire Ole Package wrapper around the file making them difficult to do anything constructive with as opposed to an actual binary stream that can be easily read out to a file and be used in a rational manner.

However embedded Ole wrapper packages is what I have and I am hoping there is some easy way to consume the entire package in Excel.

Can I take an embedded Ole object that is a picture and write it into some sort of control in Excel and have it display the picture - preferably from a recordset?

I am using Office 2013.

A less favorable prospect would be to open the picture for each record, save it and then use files directly - I can find using files but did not pay much attention as best I can tell no way to save files. I am assuming the saving would have to be manual but if there is code / automation I would welcome it. Currently I have Win 7 and paint... obviously OS upgrade is coming in the not too distance future thanks to the end of update support for Win 7 - betting I have 3 to 6 months left on it.

The closest thing to useful I found is the below but that is going the wrong way. I have not played with bound ole objects. I guess that is next on my search for the kitchen sink.

https://stackoverflow.com/questions/48709284/savin...

RE: Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

(OP)
Out of that stackoverflow post, I finally figured out how to functionally double click the bound object frame for a picture which opens paint on my machine...

Where bofLogo is the bound object frame control containing the image.

CODE

bofLogo.Verb = acOLEVerbOpen
  bofLogo.Action = acOLEActivate 

I did not get the sendkeys quite right to save it but I did find that doing save as manually did not yield a file I could reopen in paint. It appears corrupt not unlike streaming out the entire blob to disk. My question then is what am I doing wrong that opening the Ole object in application and doing save as does not yield good results?

RE: Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

(OP)
Figured out what I was doing wrong... F12 does not work... you have to use other method but I have a new problem
*Note currently on Win 7 with paint...

Alt+f, Down, right, b...

CODE

'Open Save As dialog with bitmap selected
  SendKeys ("%f") 'Alt+f
  SendKeys ("{DOWN}{RIGHT}") 'Down arrow, Right arrow: (Select Save Copy when opened from OLE object as this is on win 7)
  SendKeys ("b") 'b for bitmap option
  'Cursor lands in filename box 

Catch 22 when I try to sendkeys the path into the file name at best I am loosing several leading characters.

I have even tried doevents and the sleep api call to no avail.

Even with the sleep, it seems to not put the cursor in the file name box while code is executing...

Dumbfounded at the moment.

RE: Write Ole Package picture from OLE Object Access field into some sort of control in Excel sheet

(OP)
Finally...


CODE

'Open OLE Paint Picture
  bofLogo.Verb = acOLEVerbOpen
  bofLogo.Action = acOLEActivate 
  
  'Open Save As dialog with bitmap selected
  AppActivate "Paint" 'Activate paint application for good measure
  SendKeys ("%f") 'Alt+f
  SendKeys ("{DOWN}{RIGHT}") 'Down arrow, Right arrow: (Select Save Copy when opened from OLE object as this is on win 7)
  SendKeys ("b") 'b for bitmap option
  AppActivate "Paint" 'For some reason giving focus while the save as dialog box is loading is where the magic is
  
  Debug.Print strLogosPath & Me!txtLogoDescription & ".bmp"
  
  Sleep 750  'pause for save as dialog to load...

  
  SendKeys (strLogosPath & Me!txtLogoDescription & ".bmp") 'Enter File Name and path
  DoEvents
  SendKeys ("%s") 'alt + s (Save)
  DoEvents 'cede execution to OS
  Sleep 10 'Wait 10 ms because weird happens here in general with file I/O
  SendKeys ("%{F4}") 'alt + F4 - Close Windows Applicaiton (Paint) 

It works but on a hope and a prayer, enjoy..
Solved.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close