更新
340 字
2 分钟
更新
更新
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongSub 获取标签名(control As IRibbonControl, ByRef returnedVal) returnedVal = "报告小帮手 V2.6"End SubSub 获取标签日期(control As IRibbonControl, ByRef returnedVal) returnedVal = "20220814更新"End SubSub 签名(control As IRibbonControl, ByRef returnedVal) returnedVal = "公众号:茶瓜子的休闲馆"End SubSub 检查更新(control As IRibbonControl) 本地 = Val(ThisVersion) 最新 = Val(Getver) If 本地 <> 最新 Then y = MsgBox("存在新版本,是否进入主页查看最新版?", vbYesNo) If y = 6 Then OpenWeb End If Else MsgBox "当前版本为最新版" End IfEnd SubPublic Function ThisVersion() ThisVersion = "2.6"End FunctionPublic Function Getver() Dim Json As Object URL = "http://api.gzaudit.com/xbs/wd/" res = GetData(URL, "UTF-8") Set Json = JsonConverter.ParseJson(res) Getver = Json("版本")End FunctionSub OpenWeb() ShellExecute 0&, vbNullString, "www.gzaudit.com", vbNullString, vbNullString, vbNormalFocusEnd SubFunction GetData(StrUrl, CodePageX) Dim oHtml As Object Set oHtml = VBA.CreateObject("WinHttp.WinHttpRequest.5.1") Dim sUrl As String sUrl = StrUrl Dim sCharset As String sCharset = CodePageX With oHtml .Open "GET", sUrl, False .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" .Send '获取返回的字节数组 bResult = .ResponseBody '按照指定的字符编码显示 sResult = BytesToStr(bResult, CodePageX) 'Debug.Print sResult End With GetData = sResult Set oHtml = NothingEnd FunctionPublic Function BytesToStr(strBody, CodeBase) Dim objStream Set objStream = CreateObject("Adodb.Stream")
With objStream .Type = 1 .Mode = 3 .Open .Write strBody .Position = 0 .Type = 2 .Charset = CodeBase '"GB2312" ' BytesToStr = .ReadText .Close End With Set objStream = NothingEnd Function支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!
相关文章智能推荐
1
【VBA案例001】实现VLOOKUP功能
程技2023-10-23
2
【VBA案例002】一对多查询
程技2023-10-23
3
【VBA案例003】模糊查询
程技2023-10-23
4
【VBA案例004】自动填充表单
程技2023-10-23
5
【VBA案例005】自动汇总表单
程技2023-10-23
随机文章随机推荐
樊笼










