This article was previously published under Q198466
Moderate: Requires basic macro, coding, and interoperability skills.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Table: tblLoadOLE
------------------------
Field Name: OLEID
Data Type: AutoNumber
Field Name: OLEPath
Data Type: Text
Field Size: 255
Field Name: OLEFile
Data Type: OLE Object
Table Properties: tblLoadOLE
----------------------------
PrimaryKey: OLEID
Form: frmLoadOLE
------------------------
Text Box:
Name: SearchFolder
Text Box:
Name: SearchExtension
Text Box:
Name: OLEClass
Command Button -------------- Name: cmdLoadOLE Caption: Load Files
Private Sub cmdLoadOLE_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
[OLEFile].Class = [OLEClass]
[OLEFile].OLETypeAllowed = acOLEEmbedded
[OLEFile].SourceDoc = [OLEPath]
[OLEFile].Action = acOLECreateEmbed
' Check for next OLE file in the folder.
MyFile = Dir
' Go to new record on form.
DoCmd.RunCommand acCmdRecordsGoToNew
Loop
End Sub
Keywords: KB198466, kbprogramming, kbhowto