添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
I have an access program that needs to download and load XML data from a site. The code i'm using is below. It is having two problems (and i've tryed a few other syntaxes to save the file...)
1) The Save File dialog box is opening up, even tho i do pass in a path (and i've tried with both one \ and with \) and use FALSE for the second argument...
2) Even when i type the filename manually in the dialog box, it only gives options to save as HTML, not as XML. The file is only understood if it is XML. Note that if i manually use file-save as in the IE window that access has opened in the code above and then save it as xml, the saved file is fine and can be loaded...
Any thoughts on how i can save the correctly opened file as XML successfully?
I'm looking around and see the XML DOM stuff, and that would be able to do it i think, but I don't know how to use these functions on the document object instead of the HTML document which is automatically used for the InternetExplorer.Application Activex Control's document property...
Thanks,
*** BEGIN CODE ***
Private Sub DownloadData_Click()
On Error GoTo Err_DownloadData_Click
Dim IE As Object
Dim URL As String
Dim FileName As String
Dim Password
Password = Me!Password
If IsNull(Password) Or Len(Password) < 1 Then
MsgBox ("Please enter the password for user " & Me!UserName)
Exit Sub
End If
Set IE = CreateObject("InternetExplorer.Application")
URL = Me!DataURL
IE.Navigate URL
IE.Visible = True
While IE.busy
DoEvents 'wait until IE is done loading page.
IE.Document.All("ilogin").Select
IE.Document.All("ilogin").Value = Me!UserName
IE.Document.All("ipassword").Select
IE.Document.All("ipassword").Value = Me!Password
SendKeys "{ENTER}"
While IE.busy
DoEvents 'wait until IE is done loading page.
'EVERYTHING WORKS FINE ABOVE
'Save the XML
FileName = Me!DataPath & "\temp.html"
IE.Document.ExecCommand "SaveAs", False, FileName
' THE ABOVE COMMAND OPENS UP THE SAVEAS DIALOG, DOENS"T SAVE AUTOMATICALLY, AND THEN EVEN IF YOU USE THAT IT"S SAVED AS HTML NOT XML.
'SendKeys "{ENTER}"
While IE.busy
DoEvents 'wait until IE is done loading page.
Exit_DownloadData_Click:
Exit Sub
Err_DownloadData_Click:
MsgBox err.Description
Resume Exit_DownloadData_Click
End Sub​
Right, that's what i was suggesting i use the XML Dom for...
My question then is how do i load it from a URL when i'm going to only get to that URL if i've already entered the username and password like I did in the code snippet above...
Also, notice plz that the page itself didn't have a password and user name in authentication in it. I had to enter those fields in text boxes and then click the button on the screen (or do ENTER). Therefore I haven't been able to get the Open method to work with username and password supplied. (It may work, i just haven't been able to figure it out... Is there a way to enter information in fields like was done in the code snippet?
Thanks!