12 minutes ago: OK, I think I got the pesky Javascript error fixed. If you still see any popup error messages let me know. Thanks.  Dismiss
Computer Learning Zone CLZ Access Excel Word Windows

My view is that if there is no evidence for it, then forget about it.

-Carl Sagan
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Back to Access Open Other Programs Seminar    Comments List
VB code Upload Images   Link   Email  
Richard Lanoue 
7 years ago
I'd like to know if there is a VB code that will open a folder the way you use theses ShellExec Commands...BUT the folder ipes up to specific View Settings namely Extra Large all the time. I tried saving it but the settings eventually go to something else.  Also some folders I want the icons to be in List View and others in Extra Large view... Can you also make the window that opens up have a specific Groupby setting all the time?

Reply from Alex Hedley:

Found on another Forum. I haven't tested this.


Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
                ByVal hwnd As Long, _
                ByVal lpOperation As String, _
                ByVal lpFile As String, _
                ByVal lpParameters As String, _
                ByVal lpDirectory As String, _
                ByVal nShowCmd As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
                ByVal lpClassName As String, _
                ByVal lpWindowName As String) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
                ByVal hWnd1 As Long, _
                ByVal hWnd2 As Long, _
                ByVal lpsz1 As String, _
                ByVal lpsz2 As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
                ByVal hwnd As Long, _
                ByVal wMsg As Long, _
                ByVal wParam As Long, _
                lParam As Any) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Enum FolderView
    viewDEFAULT = 0
    viewICON = &H7029
    viewLIST = &H702B
    viewREPORT = &H702C
    viewTHUMBNAIL = &H702D
    viewTILE = &H702E
End Enum

Private Const SW_SHOWNORMAL As Long = 1
Private Const WM_COMMAND = &H111

Private Sub Command1_Click()
    OpenFolder "C:\", viewREPORT
End Sub

Private Sub OpenFolder(ByVal sFolderPath As String, Optional ByVal eView As FolderView = viewDEFAULT)
    Dim N As Long, lhWnd As Long, lPrevhWnd As Long
    If Len(Dir(sFolderPath, vbDirectory)) = 0 Then Exit Sub
    lPrevhWnd = FindWindow("CabinetWClass", vbNullString)
    ShellExecute Me.hwnd, "Open", sFolderPath, vbNullString, vbNullString, SW_SHOWNORMAL
    If eView Then
            DoEvents: N = N + 1
            lhWnd = FindWindow("CabinetWClass", vbNullString)
        Loop Until Not (lPrevhWnd = lhWnd Or lhWnd = 0) Or N = 100000
        If N = 100000 Or lhWnd = 0 Then Exit Sub
        Call Sleep(100)
         lhWnd = FindWindowEx(lhWnd, 0&, "SHELLDLL_DefView", vbNullString)
        SendMessage lhWnd, WM_COMMAND, ByVal eView, 0&
    End If
End Sub

GetOpenFileName: Set an Open/Save Dialog's Initial Listview View

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Open Other Programs Seminar.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 2/22/2024 6:21:42 PM. PLT: 0s