Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Workbook Access – Open WorkBook

Opens an Excel workbook in the specified Excel.Application instance, or returns a reference if it is already open.

If the workbook is already open in the given Excel application (based on file name match), it is returned without reopening. If the file is not open and a valid path is provided, it is opened with Local:=True . If an error occurs during the process, the function returns Nothing.

VB
    Public Function xlOpenWorkBook(CallingApp As Excel.Application, 
                                   FileName As String) As Excel.Workbook

        Try
            'Open Data Workbook
            If Not xlIsExcelFileOpened(CallingApp, Path.GetFileName(FileName)) Then

                If FileName <> "" Then
                    Return CallingApp.Workbooks.Open(FileName, Local:=True)
                End If

            Else
                Return CallingApp.Workbooks(Path.GetFileName(FileName))
            End If

        Catch ex As Exception
        End Try

        Return Nothing
    End Function

Posted by ipercube


© 2026 Ipercube Design