Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I install Common Dialog Control comdlg32 for Access 97

Status
Not open for further replies.

dan123

IS-IT--Management
Mar 26, 2001
3
IN
I use Access 97 in windows 95

I have downloaded comdlg32.ocx version 6.00.8418 from the net and placed it in c:\windows\system directory

I go to use it in a form and it keeps on saying I have no license for it

I have run the command
regsvr32 comdlg32.ocx
to register it

I have also loaded VB5 Runtime Library as denoted by some FAQ's on the net

Nothing seems to work.


In short. What is the installation process for a common dialog in access 97. How can I license it and use it. Do I have the right version

Please help me on this one.

 
You can't. But you can do it in code. The code below was from an example on a web site and is perfectly ok to use. It's only calling Windows API after all.

DECLARATIONS
Type tagOPENFILENAME
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

YOU STILL NEED Comdlg32.dll

Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OPENFILENAME As tagOPENFILENAME) As Long
Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (OPENFILENAME As tagOPENFILENAME) As Long

Dim OPENFILENAME As tagOPENFILENAME

Global Const OFN_READONLY = &H1
Global Const OFN_OVERWRITEPROMPT = &H2
Global Const OFN_HIDEREADONLY = &H4
Global Const OFN_NOCHANGEDIR = &H8
Global Const OFN_SHOWHELP = &H10
Global Const OFN_ENABLEHOOK = &H20
Global Const OFN_ENABLETEMPLATE = &H40
Global Const OFN_ENABLETEMPLATEHANDLE = &H80
Global Const OFN_NOVALIDATE = &H100
Global Const OFN_ALLOWMULTISELECT = &H200
Global Const OFN_EXTENSIONDIFFERENT = &H400
Global Const OFN_PATHMUSTEXIST = &H800
Global Const OFN_FILEMUSTEXIST = &H1000
Global Const OFN_CREATEPROMPT = &H2000
Global Const OFN_SHAREAWARE = &H4000
Global Const OFN_NOREADONLYRETURN = &H8000
Global Const OFN_NOTESTFILECREATE = &H10000

Global Const OFN_SHAREFALLTHROUGH = 2
Global Const OFN_SHARENOWARN = 1
Global Const OFN_SHAREWARN = 0

Function OpenCommDlg(cForm As Form, cFilter As String, cStartDir As String) As String
Dim Message$, FileName$, FileTitle$, DefExt$
Dim Title$, szCurDir$
Dim APIResults As Long
Dim i As Integer

On Local Error GoTo 0



'* Allocate string space for the returned strings.
FileName$ = Chr$(0) & Space$(255) & Chr$(0)
FileTitle$ = Space$(255) & Chr$(0)


'* Set up the default directory
If cStartDir = "" Then
cStartDir = CurDir$ & Chr$(0)
Else
cStartDir = cStartDir & Chr$(0)
End If

'* Set up the data structure before you call the GetOpenFileName

OPENFILENAME.lStructSize = Len(OPENFILENAME)
OPENFILENAME.hwndOwner = 0&
OPENFILENAME.lpstrFilter = cFilter
OPENFILENAME.nFilterIndex = 1
OPENFILENAME.lpstrFile = String(257, 0)
OPENFILENAME.nMaxFile = Len(OPENFILENAME.lpstrFile) - 1
OPENFILENAME.lpstrFileTitle = OPENFILENAME.lpstrFile
OPENFILENAME.nMaxFileTitle = OPENFILENAME.nMaxFile
OPENFILENAME.lpstrTitle = "Find"
OPENFILENAME.flags = 0
'OPENFILENAME.lpstrCustomFilter
'OPENFILENAME.nMaxCustFilter
'OPENFILENAME.nFileOffset
'OPENFILENAME.nFileExtension
'OPENFILENAME.lCustData
'OPENFILENAME.lpfnHook
'OPENFILENAME.lpTemplateName

OPENFILENAME.hInstance = GetWindowLong(cForm.hwnd, 0)
OPENFILENAME.lpstrInitialDir = cStartDir

'* This will pass the desired data structure to the Windows API,
'* which in turn uses it to display the Open Dialog form.

APIResults = GetOpenFileName(OPENFILENAME)

If APIResults <> 0 Then

'* Note that FileName$ will have an embedded Chr$(0) at the
'* end. You may wish to strip this character from the string.

For i = 1 To Len(OPENFILENAME.lpstrFile) - 1
If Asc(Mid(OPENFILENAME.lpstrFile, i, 1)) = 0 Then
OPENFILENAME.lpstrFile = Left$(OPENFILENAME.lpstrFile, i - 1)
Exit For
End If
Next i

OPENFILENAME.lpstrFile = Trim$(OPENFILENAME.lpstrFile)

' i = InStr(OPENFILENAME.lpstrFile, 0)
' If i > 0 Then
' OpenCommDlg = Left$(OPENFILENAME.lpstrFile, i - 1)
' Else
OpenCommDlg = OPENFILENAME.lpstrFile
' End If

Else
OpenCommDlg = &quot;&quot;
End If

End Function

I commented out some bits that didn't work.

And you call it thus

cImportFileName = OpenCommDlg(Forms!ImportOrders, &quot;htm(*.htm)&quot; & Chr$(0) & &quot;*.htm;*.htm&quot; & Chr$(0), cPath)
If cImportFileName = &quot;&quot; Then
i = MsgBox(&quot;No File Selected&quot;, vbOKOnly, APPLNAME)
Exit Sub
End If

It's actually a lot less frightening than it looks. Copy and paste and don't read it! I have code for the other common dialogues too.

As it goes on a bit, mail me and I'll send it.

Another one for the Useful Bits of Code Forum?

Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top