Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vba for excel if then?

Status
Not open for further replies.

kwill

Technical User
Aug 15, 2001
49
US
Here's what I have:
I want to make #1 run if the application is already up and #2 run if the application is not up. I think I would use some sort of if then statement, but I need help. Can you help me?
1. AppActivate ("1-bloomberg")
2. AppActivate Shell("c:\blp\wintrv\wintrv.exe")
3. newHour = Hour(Now())
4. newMinute = Minute(Now())
5. newSecond = Second(Now()) + 10
6. waitTime = TimeSerial(newHour, newMinute, newSecond)
7. Application.Wait waitTime
8. SendKeys "TOUR INSTALL{enter}"
 
Although this doesn't deal with Shell it will test to see if an Excel file is open......

Sub ifopenman()
Dim f As Integer
Dim en As String
Dim ed As String
FullFileName = ("C:\My Excel Files\Inventory Files\ML-Dan.xls")
f = FreeFile
On Error Resume Next
Open FullFileName For Binary Access Read Write Lock Read Write As #f
Close #f
If Err.Number <> 0 Then
en = Err.Number
ed = Err.Description
FileAlreadyOpen = True
Err.Clear
MsgBox FullFileName & &quot; Is already open&quot; & vbCr & vbCr & &quot;Error # &quot; & en & &quot; - &quot; & ed
Else
FileAlreadyOpen = False
End If
'then you could code something like .... If FileAlreadyOpen = True then
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top