标签:nbsp http des silent 用户 while desc lse navigate
电脑系统日期和时间,用户可以自己修改。下面的工具可以自动获取标准的北京日期和时间,并修正系统时间。
代码:
‘By 刘永富,QQ群:61840693 Public IE As InternetExplorer Sub GetDateTime() On Error GoTo Err1: Dim span_date As MSHTML.HTMLSpanElement Dim span_time As MSHTML.HTMLSpanElement Dim Sdate As String, Stime As String Set IE = New InternetExplorer With IE .Silent = True .Visible = False .navigate "https://www.baidu.com/s?wd=%E5%8C%97%E4%BA%AC%E6%97%B6%E9%97%B4" While .readyState <> READYSTATE_COMPLETE DoEvents Wend Do Set span_date = .document.getElementsByClassName("op-beijingtime-date").Item(0) DoEvents If span_date Is Nothing = False Then If IsDate(span_date.innerText) Then Exit Do End If Loop Sdate = Trim(span_date.innerText) Set span_time = .document.getElementsByClassName("op-beijingtime-time").Item(0) Stime = Trim(span_time.innerText) Date = CDate(Sdate) Time = CDate(Left(Stime, 5) & ":" & Right(Stime, 2)) .Quit End With Exit Sub Err1: MsgBox Err.Description End Sub
附件下载:
标签:nbsp http des silent 用户 while desc lse navigate
原文地址:https://www.cnblogs.com/ryueifu-VBA/p/9215309.html