Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Exe file search and insertion?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Exe file search and insertion?

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Exe file search and insertion?

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




  #4   Report Post  
Posted to microsoft.public.excel.programming
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Exe file search and insertion?

I suspect it might take a while for the code to search an entire drive. I
don't see anywhere there would be an infinite loop (but then i don't know
how you are calling the routine).

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Exe file search and insertion?

Thanks alot Tom Ogilvy,

I got this to work, and you were right it just took a bit longer than I
thought to search the hard drive. Im thinking I need to reword the code to
do two loops, so search for the file in the "default location" and if not
found there then search the "c" drive for that file. Thanks, you've been a
big help.

"Tom Ogilvy" wrote:

I suspect it might take a while for the code to search an entire drive. I
don't see anywhere there would be an infinite loop (but then i don't know
how you are calling the routine).

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Exe file search and insertion?

The search in the default location is fairly straightforward

if dir("C:\Program Files\RealVNC\vncviewer.exe ") < "" then
Shell ("C:\Program Files\RealVNC\vncviewer.exe -config
C:\temp\v4-xxxx.vnc")
Else
search the drive

End if

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
Thanks alot Tom Ogilvy,

I got this to work, and you were right it just took a bit longer than I
thought to search the hard drive. Im thinking I need to reword the code

to
do two loops, so search for the file in the "default location" and if not
found there then search the "c" drive for that file. Thanks, you've been

a
big help.

"Tom Ogilvy" wrote:

I suspect it might take a while for the code to search an entire drive.

I
don't see anywhere there would be an infinite loop (but then i don't

know
how you are calling the routine).

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
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








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Exe file search and insertion?

This is working great, but I have been trying to make this more "robust" by
adding the feature of verifying both sections of the shell, here is what I
have so far but I cannot figure out why this isnt working. If you have any
ideas or could give me any help with this it would be much appreciated:

Sub AA()
Dim sStr As String, bFound As Boolean
Dim sStr2 As String, bFound2 As Boolean
Dim i As Long
Dim j As Long
Dim exe_path As String
Dim config_path As String

exe_path = "C:\Program Files\RealVNC\vncviewer.exe"
config_path = "C:\temp\v4-5900.vnc"

sStr = ("Z")
sStr1 = ("-config")
sStr2 = ("F")
bFound = False

With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = True
.Filename = "vncviewer.exe"
.FileType = msoFileTypeAllFiles
If Dir(exe_path) < "" Then
With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = True
.Filename = "v4-5900.vnc"
.FileType = msoFileTypeAllFiles
If Dir(config_path) < "" Then
Shell (exe_path & " -config " & config_path)

Else
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If InStr(1, .FoundFiles(i), "\vncviewer.exe", vbTextCompare) Then
bFound = True
sStr = Replace(sStr, "Z", .FoundFiles(i))
Exit For

For j = 1 To .FoundFiles.Count
If inStr2(1, .FoundFiles(j), "v4-5900.vnc", vbTestCompare) Then
bFound2 = True
sStr2 = Replace(sStr, "F", .FoundFiles(j))
Exit For
End If
Shell ("Z" + "-config" + "F")

Next i
If Not bFound Then _
MsgBox "Files Not Found!"
Else
MsgBox "Files Not Found!"
End If


End If

End With

End Sub

Thanks for your time..

"Tom Ogilvy" wrote:

The search in the default location is fairly straightforward

if dir("C:\Program Files\RealVNC\vncviewer.exe ") < "" then
Shell ("C:\Program Files\RealVNC\vncviewer.exe -config
C:\temp\v4-xxxx.vnc")
Else
search the drive

End if

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
Thanks alot Tom Ogilvy,

I got this to work, and you were right it just took a bit longer than I
thought to search the hard drive. Im thinking I need to reword the code

to
do two loops, so search for the file in the "default location" and if not
found there then search the "c" drive for that file. Thanks, you've been

a
big help.

"Tom Ogilvy" wrote:

I suspect it might take a while for the code to search an entire drive.

I
don't see anywhere there would be an infinite loop (but then i don't

know
how you are calling the routine).

--
Regards,
Tom Ogilvy

"SATATOM" wrote in message
...
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









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File name insertion in cell balterson Excel Worksheet Functions 3 October 22nd 09 09:35 PM
file search or search files Richad Excel Discussion (Misc queries) 0 October 22nd 09 07:56 PM
Turning a text file name into a search and linking the file as a hyperlink AlistairM Excel Discussion (Misc queries) 1 January 26th 06 04:55 AM
File Search MD Excel Programming 2 August 19th 04 09:28 PM
Macro to search from one file & place on another file. Luong[_2_] Excel Programming 0 May 6th 04 04:53 PM


All times are GMT +1. The time now is 11:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"