用Excel VBA如何判断某单元格的超链接是否确实存在?

2020-05-02 科技 503阅读
以超链接为某网站为例,代码及注释如下:
Const myURL = "http://fund.eastmoney.com/favor/"
Application.ScreenUpdating = False
Application.Cursor = xlWait

'运行时会出现错误提示,中止程序,更改j初值后重新运行
Dim Ie, dmt
Dim mycol, myrow As Integer
Dim tijiao As String '存储提交命令

tijiao = "&cmdok=%C8%B7%B6%A8" 'cmdok=%C8%B7%B6%A8为提交命令

Set Ie = CreateObject("InternetExplorer.Application")
With Ie
.MenuBar = 0 '不显示IE对象菜单栏
.AddressBar = 0 '不显示IE对象地址栏
.Toolbar = 0 '不显示IE对象工具栏
.StatusBar = 0 '不显示IE对象状态栏
.FullScreen = 0 '全屏化IE对象
.Width = 800 '设置IE对象宽度
.Height = 600 '设置IE对象高度
.Resizable = 0 '设置IE对象大小是否可以被改动
.Visible = 0 '设置是否可见
.navigate myURL '导航到查询网址并提交
m = "NO"
Sleep 15000 'sleep库函数
Do Until .readystate = 4 '4=等网页完全打开
If .readystate = 4 Then
m = "OK"
End If
DoEvents
Loop

If m = "NO" Then
msgbox myURL,,"地址无效"
End If
End With
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com