Class Code for Excel, Import OLE Object Files

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: lindyr (anonymous_at_discussions.microsoft.com)
Date: 08/11/04


Date: Wed, 11 Aug 2004 16:05:28 -0700

I am attempting to import OLE object files into an Access
table using the code below. I error out on the Class
Code field. What is the Class code for MS Excel files -
is it Excel.Spread***?

The instructions give an example of " Paint.Picture
for .bmp files.", but don's say what to use for Excel
files.

Here is the detail code:

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.
          ' For Access 95 only, use the following Line of
code:
          DoCmd.DoMenuItem acFormBar, acEditMenu, 12, 4,
acMenuVer70

          ' For Access 97 only, use the following line of
code:
          'DoCmd.RunCommand acCmdRecordsGoToNew
       Loop

End Sub


Quantcast