Solved

If statement for calling modules

Posted on 2004-10-27
151 Views
Last Modified: 2010-05-02
Greetings,

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"
            frmTicketNumberList.Show
        ElseIf InStr(1, IE.Document.Title, "View", vbTextCompare) = Null Then MsgBox "There are tickets displayed on the screen."
        Else
            MsgBox "Will now update the only open ticket"
            Call fEnumWindows
        End If
    Next
0
Question by:jkrech17
    2 Comments
     
    LVL 32

    Accepted Solution

    by:
    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"
            'frmTicketNumberList.Show
            List1.AddItem IE.LocationName
            count = count + 1
        End If
    Next

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

    Author Comment

    by:jkrech17
    Erick37,

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

    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    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…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now