如何在VBA中更改相对超链接到绝对超链接 [英] How to change relative hyperlink to absolute hyperlink in VBA

查看:103
本文介绍了如何在VBA中更改相对超链接到绝对超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用CDO.Message从MS Access发送几个附加文件。

当我使用objMessage.AddAttachment时我需要指出文件的完整路径,但是所有文件的超链接都存储在我的查询(记录集)的单独列中,但仅作为相对链接。如何将其更改为绝对超链接?

完整代码如下:

I want to send several attached files from MS Access using CDO.Message.
When I use "objMessage.AddAttachment" I need to indicate full path to the file, but all hyperlinks to files stored in separate column of my query (recordset) but as relative links only. How to change it to absolute hyperlinks?
Full code as below:

展开 | 选择 | 换行 | 行号

推荐答案

请您提供相关链接的示例?我很确定你在做什么;但是,有这个例子可以确认。
Would you please provide an example of the relative link? I am fairly certain what you are doing; however, having that example would confirm.


当我在表中添加超链接时,我将其视为Folder1 \ testfile.txt,

使用VBA code Trim(rst(8))我把它作为

"#Folder1 \ testfile.txt#",

但是实际路径是C:\ DOCUMENTS \ File1 \\\ testfile.txt


似乎我得到了超链接属性的这个链接。

我只需要完整路径(绝对)没有# - 标志和任何其他信息。


我的基地位于C:\ DOCUMENTS
When I add the hyperlink in table I see it as "Folder1\testfile.txt",
using VBA code Trim(rst(8)) I get it as
"#Folder1\testfile.txt#",
but actual path is C:\DOCUMENTS\Folder1\testfile.txt

It seems that I get this link with Hyperlink properties.
I need only full path (absolute) without #-signs and any other info.

My base is located in C:\DOCUMENTS


CostasM:

我只需要完整路径(绝对)而不需要#-signs和任何其他信息。
CostasM:
I need only full path (absolute) without #-signs and any other info.



我担心这不是真的。没有没有哈希(#)字符的超链接。请参阅错误7980:HyperlinkAddress或HyperlinkSubAddress read-仅适用于超链接,了解有关超链接如何工作以及如何在需要时在代码中设置它们的更多信息。


对于您的情况,您需要提取相对的地址(除非你已经在某处获得了这些信息)。修复地址。除非它每次运行时都是相同的,否则只需要使用知识。最后,重做超链接,如链接线程中所述。请记住,任何电子邮件的收件人都必须能够从超链接中的任何内容访问该文件,因此如果驱动器号在其PC上必须相同,则它们才足够。否则你需要考虑UNC( \\Server \Share \ folders ... \ File )。

I''m afraid that is just not true. There is no hyperlink without the hash (#) characters. See Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink for more about how hyperlinks work and how to set them in code when you need to.

For your situation you will need to extract the address that is relative (unless you have that information somewhere already). Fix the address. Unless it is the same every time it''s run rou will need to use knowledge only you have. Lastly, redo the hyperlink as explained in the linked thread. Remember, the recipient of any email must be able to access the file from whatever is in the hyperlink, so drive letters are only adequate if they are necessarily the same on their PC. Otherwise you need to consider UNCs (\\Server\Share\folders...\File).


这篇关于如何在VBA中更改相对超链接到绝对超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆