insert OLE macro

biker_boy

New Member
Joined
Dec 3, 2004
Messages
24
hi, im making a database for id cards, ive produced the OLE in the table and then in a form -screenshot- but at the moment to add a picture to the form i have to right click the image box, insert object, create from file, navigate to "F:\Project\PUPIL IMG\" and select the image. the image name will be the same name as the Pupil ID number.

i found this bit of code but have spent all day trying to get it to work i was wondering if anyone had any ideas.
Code:
Private Sub cmdOleAuto_Click() 
On Error GoTo Error_cmdOleAuto_Click 
With Me![OLEMempic] 
.Enabled = True 
.Locked = False 
' Specify what kind of object can appear in the field. 
.OLETypeAllowed = acOLELinked 
' Class statement--optional for Excel worksheet. 
.Class = ".bmp" 
' Specify the file to be linked. 
' Type the correct path name. 
'C:\Casey's Stuff\Photos\DB Photo Shots\ApprenticeNumber 
.SourceDoc = "C:\\" & Me![UniqueNumber] & ".bmp" 
' Range statement--optional for Excel worksheet. 
.SourceItem = "" 
' Create the linked object. 
.Action = acOLECreateLink 
' Optional size adjustment. 
.SizeMode = acOLESizeStretch 
End With 
Exit_cmdOLEAuto_Click: 
Exit Sub 
Error_cmdOleAuto_Click: 
MsgBox CStr(Err) & " " & Err.Description 
Resume Exit_cmdOLEAuto_Click 

End Sub

thanks alot
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top