-----Original Message-----
Hi Leila,
After much puzzlement on my part I recently solved this issue once and for
all (I believe). The key was finding out Microsoft recommends NOT using an
OCX which is what the common dialog control is. For a series of reasons
having to do with DLL hell it is impossible to guarantee an OCX will
continue to work. The simple solution is to copy some free code from the
following site into a separate module (might sound scary but don't worry
this is simple) and directly use comdlg32.dll which is available on any
windows based computer.
This solution works from MS Access (which I needed) and also from VB6 or
from any other vb aware place. And the code you write is just as simple as
using the common dialog... So it really is good!
The recent revelation to me was why an OCX can't ever be guaranteed to
work.... The OCX requires a license to run and the only way to install the
license is to create a separate setup program. But even then installing any
other program can break your app...This is because a newer version of the
OCX may be installed without changing the license. So the license won't
match the newer OCX. This is why Microsoft recommends bypassing the entire
issue and working directly with the underlying comdlg32.dll which is always
available.
Here is the site with the free code followed by my code to use it. Note
another trick I include to get the path to the My Documents folder.
HTH,
Gray
Site to free code - thanks to Getz et al.
http://www.mvps.org/access/api/api0001.htm
My code to use the above and select a document from a folder. (including a
trick for getting the MyDocuments folder)
I put the Getz code into a module named dlgCommon
Dim wShell As Object 'New WshShell
Dim strPath As String
Dim blnCancel As Boolean
Dim varResult As Variant
Dim strFilter As String
Dim lngFlags As Long
On Error GoTo Err_Proc
Set wShell = CreateObject("WScript.Shell")
strPath = wShell.SpecialFolders("MyDocuments")
Set wShell = Nothing
strFilter = dlgCommon.ahtAddFilterItem