Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling the Find Files or Folders App

Posted on 1998-07-01
5
Medium Priority
?
202 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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

650 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