Solved

Calling the Find Files or Folders App

Posted on 1998-07-01
5
196 Views
Last Modified: 2010-05-03
How do you call the Find File or Folders App from a command button?
0
Comment
Question by:UpAllNite
  • 4
5 Comments
 
LVL 2

Expert Comment

by:swilt
ID: 1464655
Private Sub Command1_Click()
    Dim x As Variant
    Dim i As Integer
   
    x = Shell("Explorer", vbNormalFocus)
    If x <> 0 Then
        SendKeys "^f", True     'Ctrl f to invoke FindFiles from Explorer
        AppActivate "Exploring - C:\"
        SendKeys "%{F4}", True  'Alt F4 to close Explorer
        For i = 1 To 100
            DoEvents
        Next i
        AppActivate "Find: All Files"
    End If
End Sub

0
 
LVL 2

Expert Comment

by:swilt
ID: 1464656
Did it not work or was it not what you wanted ?
0
 

Author Comment

by:UpAllNite
ID: 1464657
It didn't work because, "Exploring - C:\" isn't always at startup, therefore AppActivate Errors occurr.  Secondly, I wanted to access the Find Files or Folders App without going through Explorer and sending SendKeys.

What I want is a call directly to the Find Files or Folders App.
0
 
LVL 2

Accepted Solution

by:
swilt earned 50 total points
ID: 1464658
Hope this works

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 Sub Command1_Click()
    Dim sDir As String
    Dim nCmd As Long, nRet As Long
   
    sDir = "c:\"
    nCmd = 1
    nRet = ShellExecute(Me.hwnd, "Open", "temp.fnd", "", sDir, nCmd)
End Sub

Private Sub Form_Load()
    Dim fh As Integer
    Dim sFile As String, sTok As String
   
    sFile = "68,70,3,32,1,48,32,32,255,255,16,32,32,32,32,32,1,32,32,32,38,32,32,32,255,255,255,255,4,32,32,32,17,55,2,32,48,32,32,32,32,32,17,55,4,32,48,32,32,32,42,32,32,32,32,32,32,32,78,84,70,70,58,15,235,119,0"
   
    fh = FreeFile
    Open "c:\temp.fnd" For Binary As #fh
    sTok = sChopStr(sFile)
    While sTok <> ""
        Put #fh, , Chr$(Val(sTok))
        sTok = sChopStr(sFile)
    Wend
    Close #fh
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Kill "c:\temp.fnd"
End Sub

Private Function sChopStr(sInp As String) As String
    Dim p As Integer
    Dim sRet As String
   
    p = InStr(sInp, ",")
    If p > 0 Then
        sRet = Left$(sInp, p - 1)
        sInp = Mid$(sInp, p + 1)
    Else
        sRet = sInp
        sRet = ""
    End If
    sChopStr = sRet
End Function

0
 
LVL 2

Expert Comment

by:swilt
ID: 1464659
Replace Form_Load with the following code and delete function sChopStr
It should still work but be a bit simpler

Private Sub Form_Load()
    Dim fh As Integer
     
    fh = FreeFile
    Open "c:\temp.fnd" For Binary As #fh
    Put #fh, , " "
    Close #fh
End Sub

0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question