小编mat*_*103的帖子

超链接(1).address只返回部分地址

我正在处理以下代码,该代码将根据链接在单击时是否有效来重新格式化包含链接的单元格:

Private Sub worksheet_followhyperlink(ByVal HL As HYPERLINK)
Dim linkReq As Object
Dim linkStatus As Integer

Application.ScreenUpdating = False
On Error GoTo linkError
Set linkReq = New MSXML2.XMLHTTP60
With linkReq
    .Open "GET", HL.address, False
    .Send
End With
linkStatus = linkReq.Status

If linkStatus = 404 Then HL.Parent.Interior.Color = rgbPink
If linkStatus <> 404 Then HL.Parent.Interior.Pattern = xlNone

If HL.Parent.Interior.Pattern = xlNone Then GoTo exitSub
Application.ScreenUpdating = True
MsgBox("Link is broken")

exitSub:
Application.ScreenUpdating = True
Exit Sub

linkError:
linkStatus = 404
Resume Next …
Run Code Online (Sandbox Code Playgroud)

excel sharepoint vba hyperlink excel-vba

5
推荐指数
1
解决办法
1141
查看次数

标签 统计

excel ×1

excel-vba ×1

hyperlink ×1

sharepoint ×1

vba ×1