Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with my Else statement
I have been working on this little project for a few days now and I cannot
figure out how to do this. I need to search a users hard drive for two files; first in thier defualt locations. If they are both found in default locations then they passed into the shell script and run, otherwise the parts that are not in thier default locations are searched for and then passed into the shell and run, else error messages for the file or files that were nto found are sent to the user. Here is my code for this if you have any ideas or tips please let me know. Sub AA() Dim sStr As String, bFound As Boolean Dim i 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 -config ") sStr = ("Z -config F") bFound = False With Application.FileSearch .NewSearch .LookIn = "C:\" .SearchSubFolders = True .Filename = "vncviewer.exe" .FileType = msoFileTypeAllFiles If Dir(exe_path) < "" Then GoTo ConfigSearch 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)) Shell sStr Exit For End If Next i If Not bFound Then _ MsgBox "RealVNC not found" Else MsgBox "RealVNC not found." End If End If End With ConfigSearch: 'label 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), "v4-5900.vnc", vbTextCompare) Then bFound = True sStr = Replace(sStr, "F", .FoundFiles(i)) Shell sStr Exit For End If Next i If Not bFound Then _ MsgBox ".VNC File Not Found." Else MsgBox ".VNC File Not Found." End If End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Statement Problem | Excel Worksheet Functions | |||
Problem with If Statement | Excel Worksheet Functions | |||
IF STATEMENT PROBLEM | Excel Worksheet Functions | |||
if statement problem | Excel Worksheet Functions | |||
IF statement problem | Excel Worksheet Functions |