以编程方式将页脚添加到 Office Word/Excel 文档
我正在寻求构建一个与此类似的解决方案: http://esqinc.com/section/products/4/idocid.html
系统所做的是将文档文件名插入到文档页脚中。这如何以编程方式实现(最好是在 .NET 中)?
I'm looking to build a solution similar to this one:
http://esqinc.com/section/products/4/idocid.html
What the system makes is insertion of a document file name into the document footer. How's that possible programmatically (preferably in .NET)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
希望这能让你开始。以下伪 C# 代码可用于向页脚添加文本。只有您必须在宏中执行此操作才能完全自动化,并确定要添加的文档名称。最后在文档保存期间调用宏以添加页脚文本。
Hoping this gets you started. The following pseudo c# code can be used to add text to footer. Only you will have to do this in a macro to completely automate this and also identify the document name to be added. Finally call in to the macro during Document Save to add the footer text.
我只是碰巧正在编写代码,我已经在 Excel 中从 C# 执行此操作...这是部分的,并且将帮助您开始...
那里的代码比您完成此特定任务所需的代码要多,但是相关行具有标题(或在每个页面顶部重复的内容)为:
编辑 - 添加
这里是 MSDN 文档的链接,可满足您的所有 Office Interop 需求。
http://msdn.microsoft.com/en-us /library/bb209015(office.12).aspx
I just happened to be working on code where I already do this in Excel from C#... This is partial, and will get you started...
There's more code there than you need for this specific task, but the relevant lines for having a header (or something that repeats at the top of each page) are:
Edit - Added
Here's a link to MSDN documentation, for all your Office Interop needs.
http://msdn.microsoft.com/en-us/library/bb209015(office.12).aspx