跳到主要內容

如何在Excel中的單元格/頁眉或頁腳中插入文件名或路徑?

假設您要將文件名或文件路徑插入Excel單元格,頁眉或頁腳,如何快速執行此操作?

使用公式在單元格中插入當前文件名或路徑

使用頁眉和頁腳功能在頁眉/頁腳中插入當前文件名或路徑

使用Kutools for Excel在單元格/頁眉或頁腳中插入當前文件名或路徑 好主意3


箭頭藍色右氣泡 使用公式在單元格中插入當前文件名或路徑

使用以下公式,您可以在指定的單元格中快速插入文件名或路徑或工作表名稱。

項目 公式
僅文件名 = MID(CELL(“ filename”),SEARCH(“ [”,CELL(“ filename”))+ 1,SEARCH(“]”,CELL(“ filename”))-SEARCH(“ [”,CELL(“ filename “))-1) 產品功能
僅文件路徑 = LEFT(CELL(“ filename”,A1),FIND(“ [”,CELL(“ filename”,A1),1)-1) C:\ Users \ dt \ Desktop \ New文件夾\
僅活動工作表名稱 = RIGHT(CELL(“ filename”),LEN(CELL(“ filename”))-FIND(“]”,CELL(“ filename”),1)) Sheet7
當前文件名,文件路徑和活動工作表名稱 = CELL(“文件名”) C:\ Users \ dt \ Desktop \ New文件夾\ [產品功能.xlsx] Sheet7

筆記:

1.將以上所需的任何公式複製到指定的單元格,您將獲得所需的結果。

2.打開的工作簿必須已保存。


箭頭藍色右氣泡 使用頁眉和頁腳功能在頁眉/頁腳中插入當前文件名或路徑

如果要將文件名或文件路徑插入wotksheet頁眉或頁腳,則可以使用“頁眉和頁腳”功能。

1。 在功能區上,單擊 插入 > 頁眉頁腳.

2。 頁眉或頁腳部分中將有三個編輯框,單擊 離開, 中央 or 令吉 要插入文件名或路徑的框。 然後在 設計 標籤,點擊 文件路徑, 文件名 or 工作表名稱 您需要插入。 看截圖:

文檔插入文件名路徑 1

然後單擊任何單元格,您會看到文件路徑或名稱或工作表名稱已插入頁眉或頁腳。 查看屏幕截圖:

將文件路徑插入標頭
文檔插入文件名路徑 2
將文件名插入頁腳
文檔插入文件名路徑 3

箭頭藍色右氣泡 使用Kutools for Excel在單元格/頁眉或頁腳中插入當前文件名或路徑

Excel的Kutools插入工作簿信息 是一種多功能工具,可以幫助您快速方便地將工作表名稱,工作簿名稱,工作簿路徑或工作簿路徑和名稱插入Excel單元格,頁眉或頁腳。

Excel的Kutools, 與以上 300 方便的功能,使您的工作更加輕鬆。 

安裝後 Kutools for Excel,請執行以下操作:(立即免費下載Kutools for Excel!)

1。 點擊 Kutools 加 > 工作簿工具 > 插入工作簿信息,請參見屏幕截圖:

doc插入工作簿信息3

2。 在 插入工作簿信息 對話框中,從左窗格中選擇要插入的工作簿信息,然後選擇要在其中插入信息的位置。 看截圖:

doc插入工作簿信息2

3。 然後點擊 OK。 如果將wotkbook信息插入到單元格中,則會得到如下結果:

文檔插入文件名路徑 6

如果您將工作簿信息插入頁眉或頁腳,則可以選擇要將信息插入的位置, 左列, or 中心。 您可以預覽來自的頁眉或頁腳 瀏覽 > 頁面佈局.

要了解有關此功能的更多信息,請訪問 插入工作簿信息.

箭頭藍色右氣泡 插入工作簿信息

小費。如果您想在第n行中插入多個空白行或列,請嘗試使用Kutools for Excel的 插入空白行和列 如以下屏幕截圖所示。 它在60天內無限制地提供完整功能, 請下載並立即免費試用。

在Excel範圍內以特定間隔批量插入空白行或列

如果要在每隔一行中插入空白行,則可能需要一一插入,但 插入空白行和列 of Excel的Kutools 可以在幾秒鐘內完成這項工作。 點擊免費試用30天!
doc插入空白行列
Kutools for Excel:擁有300多個便捷的Excel加載項,可以在30天內免費試用。

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
What's the function to display and file path and file name WITHOUT the active sheet name? Example: C:\Users\dt\Desktop\New folder\products features.xlsx
This comment was minimized by the moderator on the site
Hello, Lydeth Chea
To only display the file path and name without the sheet name, please apply the below formua:
=SUBSTITUTE(LEFT(CELL("filename"), FIND("]", CELL("filename"))-1), "[", "")


Please have a try, thank you!
This comment was minimized by the moderator on the site
Is there an automated way to pass the current Excel filename (no file path, no extension) to the current worksheet name?
This comment was minimized by the moderator on the site
Is it possible to turn a file path in an excel print title into a clickable hyperlink? I would like to publish the excel file as a pdf with a clickable hyperlink in the footer.
This comment was minimized by the moderator on the site
Hi I have about 90 workbooks, and in each workbook i have 5 sheets, i want to put in a new column in every sheet across these workbooks to input the year.
This comment was minimized by the moderator on the site
Hi, correct formula for filename without path is: =MID((CELL("filename"));((SEARCH("[";(CELL("filename"))))+1);((SEARCH("]";(CELL("filename"))))-((SEARCH("[";(CELL("filename"))))+1))) (semicolon in MID and SEARCH funtions, and -1 --> +1 at the end) bye
This comment was minimized by the moderator on the site
For filename without extension: =MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-5)
This comment was minimized by the moderator on the site
This gives an error.
This comment was minimized by the moderator on the site
shouldn't be 6?
This comment was minimized by the moderator on the site
-6 was the correct for me on MS Office 2016 :)
This comment was minimized by the moderator on the site
On mine it works well. However, it finishes with a "." at the end. If you put 6 instead it will return without the ".". It basically works counting the characters which "+1" in the formula is the first character and the "-5" is the amount of characters that are not showing counting from the front. So, if you want to catch only the middle characters eg. (XXXXX from a document named ZZ-YY-WW-XXXXX from a extension .xlsm) you can input as per below:

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+10,SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))-15)
This comment was minimized by the moderator on the site
when i am using this function in excel 1 (this is the filename) , and then i open excel 2, the cell in excel 1 changes from "excel 1" to "excel 2". Please advise, how to prevent this.
This comment was minimized by the moderator on the site
Yes, I am having the same problem, this formula seems to point to a variable that is not tied to the actual spreadsheet of the cell the formula exists in but instead to the currently selected spreadsheet or similar.
This comment was minimized by the moderator on the site
I have the same problem when opening a different excel document. Is there a way to leave the file name with the current file?
This comment was minimized by the moderator on the site
You prolly already found this solution. But I figured I'd add it for any future searchers. :-) Simply add the third option, the "A1" reference, to each of the CELL functions as follows: =CELL("filename",A1) =SUBSTITUTE( LEFT(CELL("filename",A1),FIND("]",CELL("filename",A1))-1),"[","") =MID(CELL("filename",A1),SEARCH("[",CELL("filename",A1))+1, SEARCH("]",CELL("filename",A1))-SEARCH("[",CELL("filename",A1))-1)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations