使用vba保存Javascript IE创建的文件

使用vba保存Javascript IE创建的文件,javascript,vba,internet-explorer,Javascript,Vba,Internet Explorer,我有一个例程,可以登录并从您登录的页面调用脚本,但此报告可以从internet保存,我需要它自动保存,无需用户干预 Sub ConnectWeb() Dim ie As InternetExplorer Dim C Dim ULogin As Boolean, ieForm Dim MyPass As String, MyLogin As String Dim Linha As Integer Dim PN As String MyLogin = Application.InputBox("Po

我有一个例程,可以登录并从您登录的页面调用脚本,但此报告可以从internet保存,我需要它自动保存,无需用户干预

Sub ConnectWeb()
Dim ie As InternetExplorer
Dim C
Dim ULogin As Boolean, ieForm
Dim MyPass As String, MyLogin As String
Dim Linha As Integer
Dim PN As String
MyLogin = Application.InputBox("Por Favor entre com o Login", "Empresa", Default:="User", Type:=2)
MyPass = Application.InputBox("Por favor entre com a senha", "Empresa", Default:="Password", Type:=2)

Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "http://url"
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Document.all("cuser").innerText = MyLogin
ie.Document.all("cpass").innerText = MyPass
ie.Document.getElementById("cent").Value = "BR"

ie.Document.forms(0).submit
Do While ie.Busy
   DoEvents
Loop
    PN = "D515005-5304"
'JavaScript to create file
    ie.Document.parentWindow.execScript ("printPL('" & PN &         "','N%2FC','no')")


End Sub
Java脚本调用出现后,会显示一条消息,其中包含生成的文件和Internet Explorer Save选项,此时我需要自动保存文件,最好保存在特定路径中


从那时起,谢谢你的帮助。

我选择使用chrome,发现javascript通过URL发送信息,所以我使用了以下逻辑

Sub test()
Dim chromePath, PN As String
Dim Linha As Integer
chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
Linha = 2
Cells(Linha, "A").Select
Do While ActiveCell <> ""
    PN = Cells(Linha, "A").Value
    strURL = "http://cdroyal4.cdzodiac.com/cgi-bin/wspd_cgi.sh/WService=wslive/wpt/function.r?funct=print.pl&drawing-no=" & PN & "&prelim=no&rev=N%2FC&filename=" & PN
    Shell (chromePath & strURL)
    Linha = Linha + 1
    Cells(Linha, "A").Select
Loop

MsgBox "Complete", vbInformation, "Empresa"
End Sub
子测试()
暗淡的彩色带,PN为字符串
Dim Linha作为整数
chromePath=“”C:\Program Files(x86)\Google\Chrome\Application\Chrome.exe”“”
林哈=2
单元格(Linha,“A”)。选择
当ActiveCell“”时执行此操作
PN=单元(Linha,“A”)。值
strURL=”http://cdroyal4.cdzodiac.com/cgi-bin/wspd_cgi.sh/WService=wslive/wpt/function.r?funct=print.pl&drawing-否=“&PN&”&prelim=no&rev=N%2FC&filename=“&PN
外壳(chromePath&strURL)
林哈=林哈+1
单元格(Linha,“A”)。选择
环
MsgBox“完成”,vbInformation,“Empresa”
端接头
使用Chrome,下载会自动完成,从而得到预期的结果。 感谢所有复习过的人