Avatar of yazbek
yazbekFlag for Australia asked on

Problem with adding common dialog box control. "You don't have the license required to use this ActiveX Control"

When I try to add the Microsoft ActiveX control - Common Dialog (Comdlg32.ocx) the message appears:
"You don't have the license required to use this ActiveX control"

I have registered the control and the message still appears.  
I have MS Access XP and MS Access 2007 installed.
Is there are away to have the common dialog appear in MS Access without using the ActiveX control.  
Ultimately, I need to be able to select files from the common dialog box and insert the files and their path to a text box control on a form.
Thank you.
Microsoft Access

Avatar of undefined
Last Comment
yazbek

8/22/2022 - Mon
frankytee

>Is there are away to have the common dialog appear in MS Access without using the ActiveX control.  
yes you can using windows api call but i can't remember the exact declaration (i'm sure its
Comdlg32.dll) so i'll have to dig up one of my old apps from years ago when i get home.
i get blocked at work from below site but try :
www.pisarsky.com/software/source/vb6/cdlg.html 
frankytee

or try http://support.microsoft.com/kb/172859/EN-US
to debug the control
ASKER CERTIFIED SOLUTION
koutny

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
yazbek

Hi Koutny,
Thank you for your response - that sounds like what I'm looking for. I have one query and please excuse my ignorance.  
The following lines are not recognised as VBA code.  Could you please shed some light on this problem please!!!  I am using an MS Access 2002 MDB file in MS Access 2007.

VERSION 1.0 CLASS
Begin
  MultiUse = -1  'True
End
Attribute VB_Name = "CommonDialogWrapper"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
yazbek

I have found the solution - Thanks to all for your assistance:

'Place the following in a form
Private Sub cmdFind_Click()
FileToOpen
End Sub
Function FileToOpen(Optional StartLookIn) As String

 Dim OFN As gFILE
 Dim path As String
 Dim FileName As String
 Dim a As String
 
StartOver:
OFN.lStructSize = Len(OFN)
OFN.lpstrFilter = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
OFN.lpstrFile = Space$(254)
OFN.nMaxFile = 255
OFN.lpstrFileTitle = Space$(254)
OFN.nMaxFileTitle = 255

If Not IsMissing(StartLookIn) Then
 OFN.lpstrInitialDir = StartLookIn
'Else
' OFN.lpstrInitialDir = "C:\CorelDrw Files"
End If

OFN.lpstrTitle = "Please find and select the Excel File"
OFN.Flags = 0

a = GetOpenFileName(OFN)
If (a) Then
 path = Trim(OFN.lpstrFile)
 FileName = Trim(OFN.lpstrFileTitle)
 If Dir(path) <> "" Then FileToOpen = -1
 FileToOpen = Trim(OFN.lpstrFile)
 Me.FileName = FileToOpen
Else
 FileToOpen = ""
 path = ""
 FileName = ""
End If

'___________________________________________
'Place the following in a module
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As gFILE) As Long
Type gFILE
 lStructSize As Long
 hwndOwner As Long
 hInstance As Long
 lpstrFilter As String
 lpstrCustomFilter As String
 nMaxCustFilter As Long
 nFilterIndex As Long
 lpstrFile As String
 nMaxFile As Long
 lpstrFileTitle As String
 nMaxFileTitle As Long
 lpstrInitialDir As String
 lpstrTitle As String
 Flags As Long
 nFileOffset As Integer
 nFileExtension As Integer
 lpstrDefExt As String
 lCustData As Long
 lpfnHook As Long
 lpTemplateName As String
End Type