Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Excel
Imports System.Data
Imports excel = Microsoft.Office.Interop.Excel

Module Module1
    Public Function GetFormByName(formName As String) As Form
        'Dim Application As New Microsoft.Office.Interop.Excel.Application
        Dim Application As New Excel.Application
        If (formName = String.Empty) Then Return Nothing

        For Each frm As Form In Application.OpenForms

            If (frm.Name.ToUpperInvariant() = formName.ToUpperInvariant()) Then
                ' Devolvemos la referencia del formulario.
                '
                Return frm
            End If

        Next

        ' No está abierto el formulario especificado
        '
        Return Nothing

    End Function
End Module
