MickJackson
asked on
How to insert an OLE object using VBA Code
Hi,
I'm having a complete brain fried moment, and I'm fairly sure this shouldn't prove to difficult for anyone here (though I may be wrong). I am trying to add a bit map to a field in a table. It can be done easily enough using the Insert Object from the menu, but I would like the users to browse to a file (this works fine), select the image (again no problem), and then press a confirm button, and a record is created with the image embedded into the appropriate field.
I was trying to create a new record on the form (again no problem) and then setting a bound OLE Object (bound to the correct field name) using the following code..but it just objects saying
Error 2791
Can't link the OLE object or the bound or unbound object frame
Any ideas greatfully received
I'm having a complete brain fried moment, and I'm fairly sure this shouldn't prove to difficult for anyone here (though I may be wrong). I am trying to add a bit map to a field in a table. It can be done easily enough using the Insert Object from the menu, but I would like the users to browse to a file (this works fine), select the image (again no problem), and then press a confirm button, and a record is created with the image embedded into the appropriate field.
I was trying to create a new record on the form (again no problem) and then setting a bound OLE Object (bound to the correct field name) using the following code..but it just objects saying
Error 2791
Can't link the OLE object or the bound or unbound object frame
Any ideas greatfully received
' Specify Type.
OLE1.OLETypeAllowed = acOLEEmbedded
' Specify source file.
OLE1.SourceDoc = "C:\Images\ball.bmp"
' Create linked object.
OLE1.Action = acOLECreateLink
' Adjust control size.
OLE1.SizeMode = acOLESizeClip
Sorry: Drop line 1. "jpegfile" is wrong class. There is another solution with sendkeys, using the dialog, but the above seems to me better.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Lebans was the winner...took me a bit to sort it out then all hell broke loose with another project and have only just come back to this...sorry for the delay
Thanks once again for all the help
Thanks once again for all the help
Open in new window