comdlg32.dll

J

James Page

Hi all. I'm using the comdlg32.dll API as directed in:
http://www.mvps.org/access/api/api0001.htm

All works well, however, my client has asked me to that the default "view
menu" is set to Thumbnail. I've looked at the code but can't figure out what
to change.

Any suggestions?

Many thanks

James
 
J

James Page

Thanks Douglas

Took a look at the code but I think I need some asistance on how to get it
to work in VBA. I.e. - do I cut and paste part(s) of the code if so which
bit(s)?
Alter the code to get it to work in VBA and if so what function do I call
from the access command button?
(its a little advanced for me!!)

Thanks

James
 
D

Douglas J. Steele

Sorry: I'm about to leave to take my wife to the hospital for surgery.

If no one's answered this once I'm back, I'll try & remember to take a look
at it for you.
 
D

Douglas J. Steele

Hopefully not a biggie: she's getting a herniated disc repaired.

Okay, unfortunately I didn't take great notes, but I think this was all the
changes that were required.

1) Open MDialogHook.bas in Notepad, copy everything except the first line
(Attribute VB_Name = "MDialogHook") to the clipboard and paste it into a new
module. (If you've already got Option Explicit in the module, don't copy
that line from MDialogHook.bas either)

2) Find the line in DialogHookProc that says

Call SendMessage(hLV, WM_COMMAND, ByVal FCIDM_SHVIEW_REPORT,
ByVal 0&)

and change it to

Call SendMessage(hLV, WM_COMMAND, ByVal
FCIDM_SHVIEW_THUMBNAIL, ByVal 0&)

3) Save the module (may as well call it MDialogHook)

4) Open frmCommonDialogs.frm in Notepad and copy what comes after the 5
lines that start "Attribute" up to (but not including) the line Private Sub
Command1_Click() to the clipboard and paste it into a new module. (Again, if
you've already got Option Explicit in the module, don't copy that line from
frmCommonDialogs.frm either)

5) In routine GetSaveAsName, find the code

If ckUseHook.Value = vbChecked Then
.Flags = .Flags Or OFN_ENABLEHOOK
.lpfnHook = ReturnProcAddress(AddressOf MDialogHook.DialogHookProc)
End If

and remove the If construct, leaving

.Flags = .Flags Or OFN_ENABLEHOOK
.lpfnHook = ReturnProcAddress(AddressOf MDialogHook.DialogHookProc)

6) In routine GetOpenName, find the code

If ckUseHook.Value = vbChecked Then
.Flags = .Flags Or OFN_ENABLEHOOK
.lpfnHook = ReturnProcAddress(AddressOf MDialogHook.DialogHookProc)
End If

and remove the If construct, leaving

.Flags = .Flags Or OFN_ENABLEHOOK
.lpfnHook = ReturnProcAddress(AddressOf MDialogHook.DialogHookProc)

To call the FileOpen dialog, use code like:

Dim sFile As String

sFile = GetOpenName(CurrentProject.Path)

If Len(sFile) = 0 Then sFile = "No file selected."

MsgBox sFile, vbExclamation, "GetOpenFileName"


To call the FileSaveAs Dialog, use code like:

Dim sFile As String

sFile = GetSaveAsName("This File Name", CurrentProject.Path)

If Len(sFile) = 0 Then sFile = "No file selected."

MsgBox sFile, vbExclamation, "GetSaveFileName"

Hopefully that's enough to get you going. You might want to add bits from
Ken's code (what you got at http://www.mvps.org/access/api/api0001.htm) to
give you additional functionality (such as specifying file extensions of
interest and the like)
 
J

James Page

Thanks Douglas

I'll let you know how I get on ( away from the office - Bank holiday!)

James
 
J

James Page

Thanks Douglas - works a treat!
Just a minor amendment had to declare the 'Hwnd' variable.

Thanks for your help - Hope your wife feels better soon.

James
 

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