Link to home
Start Free TrialLog in
Avatar of MarcGraff
MarcGraffFlag for United States of America

asked on

CreateObject("MSComDlg.CommonDialog")???

   Dim ImportTbl
    Set ImportTbl= CreateObject("MSComDlg.CommonDialog")

on the "Set ImportTbl= CreateObject("MSComDlg.CommonDialog")"  line it gives an error stating:

Run-time error '429':

ActiveX component can't create object

This code works on my computer but not on others. I have installed the VB6 Runtime package but that did nothing.
Any help would be very appreciated.

   - Marc
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MarcGraff

ASKER

I have made the switch and it appears to work great! Thank you very much!

   - Marc
Avatar of HenryBStinson
HenryBStinson

I think You have to set a reference in "Project Components" to "Microsoft CommonDialog Control VB6" (use latest SP # you see listed.)
Then you have to be sure to include the DLL containing this in your project SETUP utility.
Here's some sample code that should work.
============================================================
    Dim oDialog             As Object   'Unfortunately, CreateObject( ) does not work if declared "As CommonDialog"
   
    If Len(sFileSpec) = 0 Then
        '----------------------------------------------------
        'Prompt to save into a UDL file
        '----------------------------------------------------
        Set oDialog = CreateObject("MSComDlg.CommonDialog.1")
        With oDialog
            .InitDir = gsAppPath
            .DialogTitle = "Save OLEDB Data Link (.UDL) File."
            .DefaultExt = ".udl"
            .Filter = "Data Link Files (*.udl) | *.udl"
           '.Action = 2  -- This is the same as calling:
            .ShowSave
            'Processing will return here after the dialog box closes.
       
            sFileSpec = Trim$(.FileName)
            If Len(sFileSpec) = 0 Then
                'User cancelled.
                GoTo CleanUpAndExit 'RETURN FALSE
            End If
        End With 'oDialog
        Set oDialog = Nothing
    End If