CommonDialog object between 2000 and 2002

B

BJ Freeman

I use CommonDialog as a late binding object in a Access VBA.
Set fileopen = CreateObject("MSComDlg.CommonDialog") this is the
C:\WINDOWS\SYSTEM32\comdlg32.ocx

this works in my office 2000
when I send the Access to a client they get an error, in Access2002.
the expression you entered as a event property setting produced the
following error:
the action requires a filename aurgment.

here is the code:
routine 1

Dim filename
filename = getfile(CurrentProject.Path, "EPOSTAGE*.txt)|EPOSTAGE*.txt")
If InStr(filename, "no files found.") > 0 Then
MsgBox " unable to find Endicia export file EPOSTAGE*txt)"
Exit Sub
End If



routine 2
Function getfile(strDir As String, strfilter As String) As String
Dim fileopen As Object ' MSComDlg.CommonDialog.1
On Error GoTo cancelerr
Set fileopen = CreateObject("MSComDlg.CommonDialog")
fileopen.CancelError = True
' Set flags
'' fileopen.Flags = cdlOFNPathMustExist
fileopen.InitDir = strDir
' ' Set filters
fileopen.Filter = strfilter '"EDI322Files (*.mfd)|*.mfd"
' Specify default filter
fileopen.FilterIndex = 2
' Display the Open dialog box
' Must have one *.mfd in the folder to start.
fileopen.ShowOpen
' Display name of selected file

getfile = fileopen.filename
Set fileopen = Nothing
Exit Function
cancelerr:
getfile = ""
Set fileopen = Nothing

End Function
 
C

Cheryl Fischer

BJ,

Probably not what you want to hear ... but let me make an alternate
suggestion: The overwhelming consensus among Access MVPs and others
responding in the Access newsgroups is *not* to use the Common Dialog
control. It is prone to versioning and licensing problems (which will
cause you no end of problems with an app distributed to clients whose
computers you have little control over).

There is code at the Access Web:
http://www.mvps.org/access/api/api0001.htm, which will give you all of the
functionality of the Common Dialog control without the headaches. There is
a function included named: TestIt() which will show you how to call it.

That having been said, your code may be failing on the following line:
filename = getfile(CurrentProject.Path, "EPOSTAGE*.txt)|EPOSTAGE*.txt")

due to the fact that you have an unbalanced set of parentheses.

hth,
 
B

BJ Freeman

thanks for the tip. what I finally was able to find out was
Set fileopen = CreateObject("MSComDlg.CommonDialog")
was causing a error 429-can not create object
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top