|
求助朋友帮我把这段程序,全部改为VBA中可运行的程序,我只会修改一点点,求朋友帮忙,谢谢!谢谢!
Local lOldSetOpt,mChanNum
Application.screenupdating = false
Application.workbooks.Add()
xlsheet = activesheet
xlsheet.Name = "税收政策库"
worksheets('税收政策库').Activate
activewindow.DisplayGridlines = false
Application.DisplayFormulaBar = false
Application.DisplayAlerts = false
ActiveWindow.DisplayWorkbookTabs = false
ActiveWindow.DisplayHeadings =true
cUrl = "http://www.chinatax.gov.cn/api/query?siteCode=bm29000fgk&tab=all&key=9A9C42392D397C5CA6C1BF07E2E0AA6F"
ccc="http://www.chinatax.gov.cn/chinatax/n810341/n810825/index.html?title="
wh = Createobject("WinHttp.WinHttpRequest.5.1")
sc = Createobject("ScriptControl")
sc.Language = "JavaScript"
UrlToTable(cUrl)
Range("A:A").numberformatlocal="YYYY-MM-DD"
Range("E:E").ShrinkToFit = false
cells(1,1).Value ="成文日期"
cells(1,2).Value ="年度"
cells(1,3).Value ="文件号"
cells(1,4).Value ="文件字号"
cells(1,5).Value ="文件名"
cells(1,1).ColumnWidth=10
cells(1,2).ColumnWidth=5
cells(1,3).ColumnWidth=5
cells(1,4).ColumnWidth=50
cdz=0
jjj=1
Range("B2").Select
Application.activewindow.freezepanes = true
Msgbox('导出成功!'&Chr(13)&Chr(13)&"文件位置:"&wj)
Function UrlToTable(cUrl)
Local nPage,cData,jsCode,i,err
nPage = 1
Do While true
cData = UrlToData(cUrl, nPage)
cData = Lower(cData)
TEXT TO jsCode TEXTMERGE NOSHOW PRETEXT 15
var data=<<cData>>
ENDTEXT
err = false
Try
sc.AddCode(jsCode)
Catch
err = true
Endtry
If err
Messagebox("获取数据失败")
Exit
Endif
If sc.CodeObject.Data.resultList.Length == 0
Exit
Endif
For Each oList In sc.CodeObject.Data.resultList
jjj=jjj+1
cells(jjj+1,1).Value=Left(oList.publishtime,10)
cells(jjj+1,2).Value =oList.customhs.c3
cells(jjj+1,3).Value =Alltrim(oList.customhs.c4)
cells(jjj+1,4).Value =Alltrim(oList.customhs.DOCNOVAL)
cells(jjj+1,5).Hyperlinks.Add(cells(jjj+1,5),oList.url,"","点击鼠标左键即可进入相应网页",Alltrim(oList.Title))
Endfor
nPage = nPage + 1
Enddo
Endfunc
Function UrlToData(cUrl, nPage)
wh.Open("POST", cUrl, 0)
wh.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
wh.Send("timeOption=0&page="+Transform(nPage)+"&pageSize=100&keyPlace=1&sort=dateDesc&qt=*")
Return wh.ResponseText
Endfunc
|
|