excel - excel超链接函数到变量
问题描述
我有很多具有超链接功能的单元格。一个例子:A1=HYPERLINK("T:\projekt1\61VWAus.xlsx";"61VWAus.xlsx" )
。我需要遍历每个单元格并检查每个超链接是否是有效文件。如何"T:\projekt1\61VWAus.xlsx"
从公式值中获取指向变量的超链接?我是否必须使用字符串操作来获取它,或者是否有任何直接功能可以仅获取超链接?谢谢
解决方案
我找到了解决方案:
Function check_hyperlink(rng As Range) As Boolean
Dim oFSO As Object
Dim str_Hyperlink As String
Dim exists As Boolean
Dim str_form As String
Dim arr_str_form As Variant
Set oFSO = CreateObject("Scripting.FileSystemObject")
str_form = rng.Cells(1, 1).Formula
If Left(str_form, 10) = "=HYPERLINK" Then
arr_str_form = Split(str_form, Chr(34))
str_Hyperlink = arr_str_form(1)
exists = oFSO.FileExists(str_Hyperlink)
If exists Then
check_hyperlink = True
Else
check_hyperlink = False
End If
Else
check_hyperlink = False
End If
End Function
推荐阅读
- excel - 如何从 Excel 激活 Word 文档?
- laravel - Flutter - 使用 laravel api 进行条带支付
- node.js - 表达猫鼬填充问题
- ruby-on-rails - 自定义属性被忽略:不限于顶级 :root 元素 (:root { ... --font-size-tiny: ... }),在 atrule
- android - 我是否正确实施了 MVP 架构?
- html - 移动多个对象的 CSS 动画
- c++ - SetPos() 在 MainWindow 之外无法正确显示
- netlogo - 海龟在到达特定补丁时不会改变航向
- sql - 连接两个表并获取给定名称的最新记录
- c# - 在 XPather.com 上使用 XML 命名空间的奇怪 XPath 行为?