Hello:
My mission is to add images to each record in a database. These images are unique for each record. This is easy to do manually but for 2000+ records, manual is not an option.
I found some MS code from KB 198466, typed it in as given and of course it failed as is typical with Access. The error is:
run time error 2777
The class argument in the CreateObject function of the Visual Basic procedure you're trying to run is invalid. This really means what? The OLE class is wrong?
The program is to find and embed images using the path, file extension and OLE Class entered into the form header.
The code follows, notes are on the right:
Private Sub cmd_LoadOLE_Click()
Dim MyFolder As String
Dim MyExt As String
Dim MyPath As String
Dim MyFile As String
Dim strCriteria As String
MyFolder = Me!SearchFolder
' get the search path
MyPath = MyFolder & "\" & "*." & [SearchExtension]
' get the first file in the path containing the file extension
MyFile = Dir(MyPath, vbNormal)
Do While Len(MyFile) <> 0
[OLEPath] = MyFolder & "\" & MyFile
' [Date] = Date$ this is my addition, fails. Not declared above?
[OLEFile].Class = [OLEClass] what are valid classes? No help from MS on this, hopeless
[OLEFile].OLETypeAllowed = acOLEEmbedded
[OLEFile].SourceDoc = [OLEPath]
[OLEFile].Action = acOLECreateEmbed error 2777 here, why?
' check for the next OLE file in the folder
MyFile = Dir
' go to the next record on the form
DoCmd.RunCommand acCmdRecordsGoToNew
Loop
End Sub
My database already has the filename and path. Can't Access just use that to embed the image, or be told to? This is what I would prefer. There must be an article on this somewhere!
Thanks very much . . . . Springfield
Start Free Trial