Improve company productivity with a Business Account.Sign Up


If statement for calling modules

Posted on 2004-10-27
Medium Priority
Last Modified: 2010-05-02

I have code that populates a listbox if there is more than one IE window that has "View" in the title. I am trying to expand on that code to make an if...then statement that will do these things:

If > 1 IE window with "View" in the title, populate listbox

If only one  IE window with "View" in the title, continue to Call fEnumWindows

If there are not any IE windows with "View" in the title, pop a msgbox indicating such.

The code below seems to perform all three actions and not correctly jump to the appropriate if...then.

Any help is appreciated.

Dim IE As New InternetExplorer
    Dim SH As New ShellWindows
    For Each IE In SH
        If InStr(1, IE.Document.Title, "View", vbTextCompare) > 1 Then
            MsgBox "Opening listbox"
        ElseIf InStr(1, IE.Document.Title, "View", vbTextCompare) = Null Then MsgBox "There are tickets displayed on the screen."
            MsgBox "Will now update the only open ticket"
            Call fEnumWindows
        End If
Question by:jkrech17
LVL 32

Accepted Solution

Erick37 earned 2000 total points
ID: 12428016
You could keep count of the windows...

Dim count As Long

For Each IE In SH
    If InStr(1, IE.Document.Title, "View") Then
        'populate listbox
        'MsgBox "Opening listbox"
        List1.AddItem IE.LocationName
        count = count + 1
    End If

If count = 0 Then
    MsgBox "No windows with " & Chr(34) & "View" & Chr(34) & " in Title"
End If

Author Comment

ID: 12428209

Thanks for the help. I used the If count along with else if to get the results I needed.


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

608 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