vba 保留从 Excel 到 PDF 的超链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45132314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Preserving hyperlinks from Excel to PDF
提问by Peter Lewis
I have an Excel workbook with about fifteen tabs that prints neatly as one page per tab. It's full of hyperlinks to web URLs, which I am creating with the HYPERLINK function.
我有一个 Excel 工作簿,其中包含大约 15 个选项卡,每个选项卡可以整齐地打印为一页。它充满了指向 Web URL 的超链接,我正在使用 HYPERLINK 函数创建这些超链接。
(1) I want to export this workbook to a PDF that preserves these links. Nothing seems to work - print to PDF, save as PDF... I also installed the latest version of Acrobat and tried their printer driver and export button (and yes I've checked "preserve links" in the Acrobat options) and none of that works either.
(1) 我想将此工作簿导出为保留这些链接的 PDF。似乎没有任何效果 - 打印为 PDF,另存为 PDF...我还安装了最新版本的 Acrobat 并尝试了他们的打印机驱动程序和导出按钮(是的,我已经检查了 Acrobat 选项中的“保留链接”),但没有也可以。
It seems like using "insert link" in the context menu rather than the HYPERLINK function works better with one or two of these methods, but this is not practical given the number of links I'm dealing with.
似乎在上下文菜单中使用“插入链接”而不是 HYPERLINK 功能在使用其中一种或两种方法时效果更好,但鉴于我正在处理的链接数量,这并不实用。
It also seems like both methods really want to format the text blue and underlined, and when I change that formatting it removes the link status in some sense? Maybe this one is just in my head but it's confusing. I also sometimes see that the "Style" of these cells in the home toolbar has reverted to "Normal" rather than Hyperlink, but changing it back to Hyperlink doesn't seem to help either.
似乎这两种方法都真的想将文本设置为蓝色和带下划线的格式,当我更改该格式时,它会在某种意义上删除链接状态?也许这个只是在我的脑海中,但它令人困惑。我有时还看到主页工具栏中这些单元格的“样式”已恢复为“正常”而不是超链接,但将其改回超链接似乎也无济于事。
Can someone shed any light on all this? Is there a VBA solution, or a different plugin to try?
有人可以解释这一切吗?是否有 VBA 解决方案或其他插件可以尝试?
(2) Not sure if this is easier or harder, but I also want to insert links from the first tab (table of contents) to the others, in a way that will be preserved in the final PDF. Same problems as above.
(2) 不确定这是否更容易或更难,但我还想插入从第一个选项卡(目录)到其他选项卡的链接,以保留在最终 PDF 中的方式。和上面一样的问题。
Thanks!
谢谢!
回答by joelgeraci
Don't print to PDF. Instead, with Acrobat installed, if you have an "ACROBAT" ribbon, select it and then "Create PDF". If you don't see the ribbon, use File-> Save As Adobe PDF.
不要打印为 PDF。相反,安装 Acrobat 后,如果您有“ACROBAT”功能区,请选择它,然后选择“创建 PDF”。如果您没有看到功能区,请使用 File-> Save As Adobe PDF。
Creating the PDF in this way will cause an add-in to run and analyze file prior to creating the PDF and do all kinds of neat stuff. One of which is to create links.
以这种方式创建 PDF 将导致加载项在创建 PDF 之前运行和分析文件,并执行各种整洁的工作。其中之一是创建链接。
回答by Damir Loncaric
My solution is:
我的解决办法是:
- Create document in Excel
- Copy content into Word
- Save as PDF from Word
- 在 Excel 中创建文档
- 将内容复制到 Word
- 从 Word 中另存为 PDF
When pasting into Word, it seems that Word automatically replaces the Hyperlink function with the shortcut menu (right mouse button) -> Add Hyperlink command, which converts successfully to PDF.
粘贴到Word时,好像Word自动用快捷菜单(鼠标右键)->添加超链接命令替换了超链接功能,成功转换为PDF。
回答by Chris
Suffered with this problem for ages so hoping what solved it for me helps someone else. If you have Acrobat Pro installed, go to the Excel sheet, in the ribbon up top click on "Acrobat", click on "Preferences", and make sure "Enable Accessibility and Reflow with tagged Adobe PDF" is NOT CHECKED.
多年来一直受到这个问题的困扰,所以希望为我解决的问题可以帮助其他人。如果您安装了 Acrobat Pro,请转到 Excel 工作表,在顶部的功能区中单击“Acrobat”,单击“首选项”,并确保未选中“使用标记的 Adobe PDF 启用辅助功能和重排”。
After doing this, using Adobe's create PDF function in Excel created working links.
这样做之后,在 Excel 中使用 Adobe 的创建 PDF 功能创建了工作链接。