?
Solved

Calling the Find Files or Folders App

Posted on 1998-07-01
5
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 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