Solved

Calling the Find Files or Folders App

Posted on 1998-07-01
5
192 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
Comment Utility
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
Comment Utility
Did it not work or was it not what you wanted ?
0
 

Author Comment

by:UpAllNite
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now