Consulting

Results 1 to 8 of 8

Thread: Missing Microsoft Common Dialog Control

  1. #1

    Missing Microsoft Common Dialog Control

    Hi Guys,
    I want to use the Color Dialog on a User Form and get the selected colour no, but I don't have the Microsoft Common Dialog Control loaded.

    When I bring up the Additional Controls panel (from the User Form code window, Tools / Additional Controls) it doesn't list the Microsoft Common Dialog so I can't select it to install it.

    I've found that the Control is COMDLG32.ocx but I don't have one of these in my Windows/System32 folder (I do have a COMDLG32.dll).

    How can I get the Common Control to appear in the AdditionalControls panel?

    I'm using WinXP and OfficeXP.

    Thanks

    Michael

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hello Michael,

    If you have missing controls, I believe this is due in part (most likely) to an incomplete installation. I would try reinstalling Excel with all of it's components. And are you sure it's not 'comctrl32.ocx'? I've uploaded the ocx file that may be the one you are looking for. Not sure if they will work or not, but it's worth a shot.

    ..

  3. #3
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Here is the 'comdlg32.dll'.

    ..

  4. #4
    Thanks Zack,

    I'll let you know how I get on.

    cheers

    Michael
    .
    .
    .
    Later
    I already had the dll, it was the ocx that I couldn't find.
    a. I did a detect and repair on Office XP but this didn't fix.
    b. I scouted around the internet a bit more and it looks like the ocx is ony for VB not VBA, the latter uses the dll so it should have worked.
    c. however, it looks like you have to be licensed to be able to use the dll via having VB developer edition or similar, which I don't have,
    d. I found something re Office 97 that said you needed to have ActiveX controls at the time you installed Office 97, but I don't remember anything about this in XP.
    e. I'm concluding that I'm not going to be able to get at the Common Dialog Control ,

    unless someone else has an idea?

    thanks

    Michael

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Michael,

    Did you try registering the dll? As discussed here:

    How about:

    regsvr32.exe [path\file.dll]

    From the commandprompt

  6. #6
    Cheers Zack,

    This is what I got trying to register the dll:

    C:\windows\system32\comdlg32.dll was loaded, but the DllRegisterServer entry point was not found.
    This file can not be registered.


    So I'm still stuck

    Thanks

    Michael

  7. #7
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    You don't need the control, besides which inserting this control in a userform creates extra overhead pls users will need this ocx registered.


    Option Explicit
    '// Ivan F Moala
    '// http://www.XcelFiles.com
    '// 16th June 2002
    
    Private Type CHOOSECOLOUR
        lStructSize    As Long
        hwndOwner      As Long
        hInstance      As Long
        rgbResult      As Long
        lpCustColors   As String
        flags          As Long
        lCustData      As Long
        lpfnHook       As Long
        lpTemplateName As String
    End Type
    Declare Function ChooseColorA _
        Lib "Comdlg32" ( _
            lpChooseColor As CHOOSECOLOUR) _
    As Long
    Declare Function FindWindowA _
        Lib "User32" ( _
            ByVal lpClassName As Any, _
            ByVal lpWindowName As String) _
    As Long
    
    Function SelectColour(Code_RGB) As Boolean
        Dim CColor As CHOOSECOLOUR
        Dim CustColors As String * 16
    With CColor
            .lStructSize = 36
            .hwndOwner = FindWindowA(vbNullString, Application.Caption)
            .lpCustColors = CustColors
            .flags = 2
        End With
    If ChooseColorA(CColor) = 0 Then Exit Function
        Code_RGB = CColor.rgbResult
        SelectColour = True
    End Function
    
    Sub Tester()
    Dim Code_RGB As Long
    If Not SelectColour(Code_RGB) Then Exit Sub
    MsgBox "The RGB code you chose:=" & Code_RGB & vbCr & _
        "Red:=" & RGBRed(Code_RGB) & vbCr & _
        "Green:=" & RGBGreen(Code_RGB) & vbCr & _
        "Blue:=" & RGBBlue(Code_RGB)
    '// Activecell colour
    'ActiveCell.Interior.Color = Code_RGB
    '// OR Selection
    Selection.Interior.Color = Code_RGB
    End Sub
    
    Public Function RGBRed(RGBCol As Long) As Integer
        '// Return the Red component from an RGB Coloor
        RGBRed = RGBCol And &HFF
    End Function
    
    Public Function RGBGreen(RGBCol As Long) As Integer
        '// Return the Green component from an RGB Colour
        RGBGreen = ((RGBCol And &H100FF00) / &H100)
    End Function
    
    Public Function RGBBlue(RGBCol As Long) As Integer
        '// Return the Blue component from an RGB Colour
        RGBBlue = (RGBCol And &HFF0000) / &H10000
    End Function
    OR

    Sub Kolour()
    Application.Dialogs(xlDialogPatterns).Show
    End Sub
    Kind Regards,
    Ivan F Moala From the City of Sails

  8. #8
    Ivan,
    Thank you for your advice, I'll try your code later.
    I'm just starting out on VBA so still have a long way to go.
    One of the reasons I wanted to get the Common Dialog working was so that I can easily get to and have control of e.g. Print options, Save As options etc.
    I've done more digging on the net and there are lots of examples using the Common Dialog control, but only one referred to needing the VB Developer s/w so I thought there must be a simpler solution.
    Anyway, I've found some sample code for Save As so with yours I'm building a library.

    Many thanks again, I think we'll call this closed.

    Cheers
    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •