Excel Addin- Get the file path of excel file RRS feed

  • Question

  • Hi,

    I want to put the filepath of my workbook in a text box.

    I tried using 'path', but it was showing error.

    Can someone tell me how to do that?

    Thanks a lot :)

    Thursday, June 28, 2012 11:42 AM


  • Hi rini!

    You are working with an Add-In, correct?

    Try this code:

    Function GetWorkbookPath(wkbName As String) As String
            For Each wkb As Excel.Workbook In Globals.ThisAddIn.Application.Workbooks
                If wkb.Name = wkbName Then
                    Return wkb.Path
                End If
        End Function

    To call the function, use code like this:  dim path = GetWorkbookPath("myWorkbook.xls")

    I hope it helps you.

    Best regards,


    • Edited by Oric.CQ Thursday, June 28, 2012 9:19 PM
    • Marked as answer by Leo_GaoModerator Wednesday, July 4, 2012 1:45 AM
    Thursday, June 28, 2012 9:18 PM