listview and imagecombo in VBA 7.1

ahankhah

New Member
Joined
May 8, 2019
Messages
6
Hi all,

I wanted to add image to combobox and found that listview or imagecombo must be used instead, but although added MSCOMCTL.OCX to "References", can't find related controls inside "Additional Controls".

Could anyone let me know what can I do?
 
@Dan_W

Thanks for responding.

Did you check at this location too? C:\Program Files\Microsoft Office\root\vfs\System\MSCOMCTL.OCX
There is no`such root\vfs sub folder in my Microsoft Office path.

BTW, I did mange to download a copy of the MSCOMCTL.OCX 32bit file from here . After that, I saved this 32bit ocx file in the SYSWOW64 directory and then successfully registered it from the command prompt ran as Admin.
UntitledCMD.png



Then back in excel, I could locate the OCX from Tools|References and add a ref to it for the workbook VBAProject.
UntitledCMD.png



Bringing up the Object Browser (F2), I can see that the MSComctlLib library is now properly referenced in the VBAProject:
UntitledCMD.png


So far so good.

Now comes the very annoying problem.

When I proceed to adding any of the OCX controls such as the TreeView, ListView etc to a UserForm at design time via the UserForm ToolBox|Additional Controls, none of the ocx controls are listed on the list of available controls:
UntitledCMD.png



So, I can't add any controls from the mscomctl.ocx @designtime which makes it next to useless (although I could still use the library and add controls @runtime via code).

I have seen people report the same issue of not finding additional controls and have read some workarounds such as loging as a diff user account or importing the added controls from a diff computer but that's just too much hassle. I just hope there is an easier fix to this problem.

Regards.

PS: BTW, the OCX file is still 32bit , so MS haven't really released a x64bit version. I may be wrong, but the 32bit OCX works only because it is installed in the SYSWOW64 directory.
 
Last edited:
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
So I don't know what's going on, or why you don't have a copy of it on your system. This is the code that I wrote to determine the bitness of certain files (vba4N6/modFileIO_Bitness.bas at main · KallunWillock/vba4N6) and reproduced below.

I downloaded the OCX you referenced above, and I tested my code below on both that OCX file and on mine (available at the above path, and also in System32). It identified yours as 32bit, and mine as 64bit. I will keep investigating, but I'm travelling over the next three days, so may not be very responsive.

1719098912481.png


' _
VBA Code:
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||                                                                                     ' _
    ||||||||||||||||||||||||||        modFileIO_Bitness (v1.0)       ||||||||||||||||||||||||||||||||||                                                                                     ' _
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
                                                                                                                                                                                            ' _
    AUTHOR:   Kallun Willock                                                                                                                                                                ' _
                                                                                                                                                                                            ' _
    NOTES:    Function used to identify the bitness of a given PE (Portable Executable) files - include executables,                                                                        ' _
              object code, DLLs (Dynamic Link Libraries), and other Windows-based files. Especially useful                                                                                  ' _
              when dealing with third-party DLLs in VBA.
                                                                                                                                                                                            ' _
    LICENSE:  MIT                                                                                                                                                                           ' _
    VERSION:  1.0        27/08/2023         Published v1.0 on Github.                                                                                                                       ' _
                                                                                                                                                                                            ' _                                                                                                                                                   ' _
    TODO:     [ ] Add GetBinaryType API (for completeness)
                                                                                                                                                                                            ' _
                    #If VBA7 Then                                                                                                                                                           ' _
                        Private Declare PtrSafe Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeW" (ByVal lpApplicationName As LongPtr, ByRef lpBinaryType As Long) As Long       ' _
                    #Else                                                                                                                                                                   ' _
                        Private Declare Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeW" (ByVal lpApplicationName As Long, ByRef lpBinaryType As Long) As Long                  ' _
                    #End If                                                                                                                                                                 ' _
                    Private Enum EXE_BINARY_TYPE_ENUM                                                                                                                                       ' _
                        SCS_32BIT_BINARY        ' 32-bit Windows-based application                                                                                                          ' _
                        SCS_DOS_BINARY          ' MS-DOS ? based application                                                                                                                ' _
                        SCS_WOW_BINARY          ' 16-bit Windows-based application                                                                                                          ' _
                        SCS_PIF_BINARY          ' PIF file that executes an MS-DOS ? based application                                                                                      ' _
                        SCS_POSIX_BINARY        ' POSIX ? based application                                                                                                                 ' _
                        SCS_OS216_BINARY        ' 16-bit OS/2-based application                                                                                                             ' _
                        SCS_64BIT_BINARY        ' 64-bit Windows-based application.                                                                                                         ' _
                    End Enum
                    
    Option Explicit
    
    Public Enum FILE_BITNESS_ENUM
        BITNESS_UNKNOWN
        x86_32BIT
        x64_64BIT
    End Enum
    
    Public Sub TestFileBitness()
        
        Dim BitnessType() As String, Result As FILE_BITNESS_ENUM
        BitnessType = Split("Unknown|32-bit|64-bit", "|")
        
        Result = GetFileBitness("C:\Program Files\Microsoft Office\root\vfs\System\MSCOMCTL.OCX")
        Debug.Print BitnessType(Result)
        
        Result = GetFileBitness("C:\Users\KJW\Downloads\mscomctl\mscomctl.ocx")
        Debug.Print BitnessType(Result)
        
    End Sub
    
    Public Function GetFileBitness(ByVal FilePath As String) As FILE_BITNESS_ENUM
        
        On Error GoTo ErrHandler
        Dim Offset      As Long: Offset = &H3C
        Dim FFile       As Long: FFile = FreeFile
        Dim FileData()  As Byte
        
        Open FilePath For Binary Access Read As #FFile
        
        ' Get the offset to PE signature
        ReDim FileData(3)
        Get #FFile, Offset + 1, FileData
        Offset = FileData(&H0) * 256 ^ 0 Or FileData(&H1) * 256 ^ 1 Or _
                 FileData(&H2) * 256 ^ 2 Or FileData(&H3) * 256 ^ 3
        Erase FileData
        
        ' Read the file bitness signature using the above PE signature offset
        ReDim FileData(5)
        Get #FFile, Offset + 1, FileData
        
        If FileData(&H0) = &H50 And FileData(&H1) = &H45 And FileData(&H2) = &H0 And FileData(&H3) = &H0 Then
            If FileData(&H4) = &H64 And FileData(&H5) = &H86 Then GetFileBitness = x64_64BIT
            If FileData(&H4) = &H4C And FileData(&H5) = &H1 Then GetFileBitness = x86_32BIT
        End If
ErrHandler:
        Close #FFile
        Erase FileData
        
    End Function
 
Upvote 0
And here is a screen capture of the controls on my system:
1719099101006.png


And my Office version:
1719099165620.png
 
Upvote 0
PS: BTW, the OCX file is still 32bit , so MS haven't really released a x64bit version. I may be wrong, but the 32bit OCX works only because it is installed in the SYSWOW64 directory.
I take back my statement above. The 32bit ocx will only work in a x64bit OS environement as long as it saved in the SYSWOW64 directory, registered and then loaded/used in x32 Office.

In other words, The 32bit ocx won't work in x64 office applications even if successfully registered and saved in SYSWOW64, which is what I have always known: A x32-bit file cannot run in a x64-bit process and vice-versa.

The reason I mistakenly thought otherwise is because I could register the cox w/o any issues and I could set a reference to the Widows Common Controls library.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,588
Messages
6,160,654
Members
451,662
Latest member
reelspike

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top