跳到主要内容

如何在Excel中的单元格/页眉或页脚中插入文件名或路径?

假设您要将文件名或文件路径插入Excel单元格,页眉或页脚中,如何快速执行此操作?

使用公式在单元格中插入当前文件名或路径

使用页眉和页脚功能在页眉/页脚中插入当前文件名或路径

使用 Kutools for Excel 在单元格/页眉或页脚中插入当前文件名或路径 好主意3


箭头蓝色右气泡 使用公式在单元格中插入当前文件名或路径

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

Item 公式 例如:
仅文件名 = 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 在单元格/页眉或页脚中插入当前文件名或路径

Kutools for Excel插入工作簿信息 是一种多功能工具,可以帮助您快速方便地将工作表名称,工作簿名称,工作簿路径或工作簿路径和名称插入Excel单元格,页眉或页脚。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

安装后 Kutools for Excel,请执行以下操作:(立即免费下载 Kutools for Excel!)

1。 点击 Kutools 加 > 工作簿工具 > 插入工作簿信息,请参见屏幕截图:

doc插入工作簿信息3

2。 在 插入工作簿信息 对话框中,从左窗格中选择要插入的工作簿信息,然后选择要在其中插入信息的位置。 看截图:

doc插入工作簿信息2

3。 然后点击 OK。 如果将wotkbook信息插入到单元格中,则会得到如下结果:

文档插入文件名路径 6

如果您将工作簿信息插入页眉或页脚,则可以选择要将信息插入的位置, , or Center。 您可以预览来自的页眉或页脚 查看 > 页面布局.

要了解有关此功能的更多信息,请访问 插入工作簿信息.

箭头蓝色右气泡 插入工作簿信息

小费。如果您想在每第 n 行中插入多个空白行或列,请尝试使用 Kutools for Excel 的 插入空白行和列 如以下屏幕截图所示。 它在60天内无限制地提供完整功能, 请下载并立即免费试用。

在Excel范围内以特定间隔批量插入空白行或列

如果要在每隔一行中插入空白行,则可能需要一一插入,但 插入空白行和列 of Kutools for Excel 可以在几秒钟内完成这项工作。 点击免费试用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 Tab 为 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