
# Tags: Test: Tested only in Excel 14.7.1 (of Office 2011) on macOS 10.12.6
Excel get file path full#
# Task: Get the front document's container folder path & its full path. (I can't presently confirm it works with Office 2016.). We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.This task is super simple with AppleScript in Excel from Office 2011.

Our goal is to help you work faster in Excel. Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. The final result returned by SUBSTITUTE is: Dave Bruns # SUBSTITUTE is configured to remove the opening square bracket by setting old_text to “[” and new_text to an empty string ("").

The result from LEFT is returned to the SUBSTITUTE function as the text argument: The LEFT function returns the first 26 characters of text.Īt this point, LEFT has removed the sheet name, but notice the opening square bracket “[” remains. The text argument is again provided by the CELL function: This number is returned directly to the LEFT function as the num_chars argument. In the previous step, we located the “]” at character 27, then stepped back to 26. We subtract 1 because we want to remove text starting with the “]” that follows the filename. The FIND function returns the location of “]” (27) from which 1 is subtracted to get 26. The location of the closing square bracket (”]") is calculated like this Note the sheet name(“Sheet1”) appears at the end. The result is a full path like this as text: The cell reference is arbitrary and can be any cell in the worksheet. The info_type argument is “filename” and reference is A1. To get the path and file name, we use the CELL function like this: Note: the CELL function is called twice in the formula because we need the path twice, once for the FIND function to locate the “]”, and once for the SUBSTITUTE function to remove the “]". CELL is a volatile function and can cause performance problems in larger or more complicated worksheets. In older versions of Excel without the TEXTBEFORE function, you can use a formula based on LEFT, CELL, FIND, and SUBSTITUTE:Īt a high level, this formula works in 4 steps: The final result is a path to the workbook like this: Legacy Excel # The CELL function is nested inside the TEXTBEFORE function, which is nested inside the SUBSTITUTE function.

In the worksheet shown above, the formula in E5 is: If you have the latest version of Excel, you should use a formula based on the TEXTBEFORE function. Otherwise, you can use the LEFT and FIND functions as explained below. The best way to do this depends on what Excel version you have. This is close to what we want, but there are still two tasks that remain: Notice the workbook name is enclosed in square brackets (""). With the info_type argument set to “filename”, and reference set to cell A1 in the current worksheet, the result from CELL will be a full path as a text string like this: This can be done with the CELL function like this: The first step in this problem is to get the workbook path, which includes the workbook and worksheet name. The sheet name and the square brackets ("") that normally enclose the file name have been removed. The result is a path and filename like this: “C:\examples\workbook.xlsx”.
