Microsoft Office 2000 Developer   

Using the DLL in an Office Application

See Also

The topic Creating a DataEnvironment Object for Use in a DLL File demonstrates how to compile a DataEnvironment object in a DLL file. The compiled DLL can now be used as a data source for any Office application.

To use the DLL as a data source

  1. From an Office application, start the Visual Basic Editor (ALT + F11).

  2. On the Tools menu, select References. A list of compiled DLLs appears in the References dialog box.

  3. Find the name of your DLL, and select it. Click OK to close dialog box.

    Note   The name of your DLL may not appear in the list of DLLs if, when creating the DLL, you used the Project Properties dialog box on the Tools menu and wrote a description in the Project Description box. If so, that description appears as the name of the DLL in the list.

  4. Insert a UserForm, then insert a command button on the UserForm. Declare an object variable using the class and member. The class name is determined by the name of the Project. The member name is determined by the name of the DataEnvironment object.
       Dim myDE As New deNwind.DataEnvironment1
    
  5. You can then use any public functions or properties of the DataEnvironment object. The example uses the ReturnRS function defined in Creating a DataEnvironment Object for Use in a DLL File.
    Private Sub PrintRecordset() 
       Dim myDE As New deNwind.DataEnvironment1
       Dim rsCustomers As New Recordset
       Set rsCustomers.DataSource = myDE.ReturnRS("Customers")
       While Not rsCustomers.EOF
          Debug.Print rsCustomers.Fields(1).Value
          rsCustomers.MoveNext
       Wend
       rsCustomers.Close
       Set myDE = Nothing
    End Sub