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 – Get First Sheet Name

Retrieves the name of the first worksheet in the specified Excel workbook.

This function opens the workbook using a new instance of Excel.Application (with Visible = False ), reads the name of the first sheet (index 1), and then closes the workbook. Errors during loading or access are silently caught and result in a Nothing return value.

VB
    Public Function xlGetFirstSheetName(WorkbookPath As String) As String

        Try
            Dim App As New Excel.Application
            App.Visible = False
            Dim wbBook = App.Workbooks.Open(WorkbookPath)
            Dim wsName As String = wbBook.Sheets(1).Name
            wbBook.Close()
            App = Nothing
            Return wsName

        Catch ex As Exception
            Dim szFunctionName As String = New Diagnostics.StackTrace().GetFrame(0).GetMethod().Name
            'ShowMessageBox(szModuleName + "." + szFunctionName + vbLf + vbLf + ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

        Return Nothing
    End Function

Posted by ipercube


© 2026 Ipercube Design