View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
SATATOM SATATOM is offline
external usenet poster
 
Posts: 7
Default Exe file search and insertion?

I tried to implement this but it seems there might be a infinite loop and it
crashes excel. Im going to try to work around this, if anyone catches where
they might be a problem please let me know. Thanks, Tom

"SATATOM" wrote:

Thank you very much for the quick reply, ill try it as soon as possible. ~Tom

"Tom Ogilvy" wrote:

You can use something like this untested code:

Sub AA()
Dim sStr As String, bFound As Boolean
Dim i As Long
sStr = ("Z -config C:\temp\v4-xxxx.vnc")
bFound = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = True
.Filename = "vncviewer.exe"
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If instr(1,.FoundFiles(i),"\vncviewer.exe",vbTextComp are) Then
bFound = True
sStr = Replace(sStr, "Z", .FoundFiles(i))
Shell sStr
Exit For
End If
Next i
If Not bFound Then _
MsgBox "RealVNC not found"
Else
MsgBox "RealVNC not found."
End If
End With

End Sub

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
Ive read many posts and have not found what im looking for exactly. I

need
to search a user's computer looking for a specific file (vncviewer.exe) to

be
exact. Then I need to insert that location into a shell command that runs
vncviewer.exe and its associated file; here is my Shell code:

Sub vnctest_macro()
Shell ("C:\Program Files\RealVNC\vncviewer.exe -config

C:\temp\v4-xxxx.vnc")
End Sub

The problem is if one doesnt have RealVnc installed in the same place this
wont work and I would like to be able to insert the correct location into

my
shell script. If they dont have the .exe at all then I would like an

error
msg. If someone has any ideas they would be greatly appreciated.

Thanks, Tom