• OLE Server Error in Access 2007 – HELP!!!

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » OLE Server Error in Access 2007 – HELP!!!

    Author
    Topic
    #464903

    I have an Access 2003 db that has a form that has a CommonDialog control on it which works fine.

    If I load it in Access 2007 on a new machine I get a “No object in this control” error and when I go to build, the CD control box is empty.

    If I try and add a CommonDialog Class from the ActiveX Controls I get “Operation on OLE object failed. OLE server may not be registered”

    I have run the Office repair utility and also completely uninstalled Office, rebooted and reinstalled but I still get the same error. I have searched but cannot find reference to which exact file needs to be registered or where to find it

    I am running Win7 and have the following references set:

    VB for Apps
    Access 12 object library
    OLE automation
    MS DAO 3.6
    MS ActiveX 2.1
    MS Forms 2.0
    MS windows common controls 6
    MS OLE DB error library

    Viewing 3 reply threads
    Author
    Replies
    • #1192164

      I’d avoid the use of the Common Dialog control.

      Access 2002 and later have the Application.FileDialog object that can be used to display a File Open, File Picker and Folder Picker dialog (but not a Save As dialog, stupidly enough).

      See the attached demo for a way to display file dialogs using only Windows API functions. To use it in your database, import the module and class module from the demo database. The form in the database demonstrates how to invoke the dialog.

    • #1192173

      Umm, thanks Hans but the coding is a bit beyond me. Could you write the code for a button to open a file picker window to select a file to be opened and read by the code?

      This what I need to emulate:

      Code:
      CommonDialog1.ShowOpen
      
      lblDetails.Caption = "Counting Records"
      
      Me!ProgressBar2.Max = 1
      
      Open CommonDialog1.FileName For Input As #1
      

      Thanks in advance.

      • #1192180

        The code could look like this:

        Code:
        Private Sub cmdOK_Click()
          Dim dlg As New CommonDialog
          Dim strFile As String
          With dlg
            ' Specify initial path
            .InitDir = Environ("UserProfile")
            ' Specify file type to display
            .Filter = "Text files (*.txt)|*.txt"
            ' Show the dialog
            If .OpenDialog = False Then
              ' User canceled the dialog
              MsgBox "No filename specified", vbInformation
              Exit Sub
            End If
            ' Get the path and filename
            strFile = .FileName
          End With
          Set dlg = Nothing
          ' Open text file
          Open strFile For Input As #1
          ' The rest of your code goes here
          ' ...
          Close #1
        End Sub
    • #1192223

      Thanks Hans, it works fine

    • #1193345

      Change the line

      Code:
      .InitDir = Environ("UserProfile")

      to

      Code:
      .InitDir = "C:MyFolderMySubFolder"

      substituting the appropriate drive and path. If you’re on a network, you can also specify a UNC path:

      Code:
      .InitDir = "\MyServerMyShareMyFolderMySubfolder"
    Viewing 3 reply threads
    Reply To: OLE Server Error in Access 2007 – HELP!!!

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: