• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

error opening excel file

Svmaxcel

Member
i made a small vba code to get data from one of our intranet file
the code went through properly, however after the last step, i get an option to Open or Save the file.(I think i can use SendKeys, not sure about the code)

the second issue here : when I manually click on open button, i get a message
The file you are trying to open abc.xls. is in a different format specified by the file extension, verify that the file is not corrupted.....

Is there any way, I can ask VBA to ignore it and open the file instead.
Also tell me of SendKey would be better or something else.please help with SendKeys code

Code:
Sub test()

Dim ie As New SHDocVw.InternetExplorer
Dim htmldoc As MSHTML.HTMLDocument
Dim htmlin As MSHTML.IHTMLElement

ie.Visible = True
ie.navigate "https://example.com"

Do While ie.readyState <> READYSTATE_COMPLETE
Loop

Set htmldoc = ie.document
Set htmlin = htmldoc.getElementById("FromDate")
htmlin.Value = Range("A1")


Set htmlin = htmldoc.getElementById("ToDate")
htmlin.Click
htmlin.Value = Range("A2")

Set htmlin = htmldoc.getElementById("Refreshdata")
htmlin.Click

Do While ie.readyState <> READYSTATE_COMPLETE
Loop

Set htmlin = htmldoc.getElementById("Download_Raw")
htmlin.Click



End Sub
 
Please help in downloading and opening excel file.
I read somewhere that I can use downloadtourl but unsure about it usage
 

Search for samples within this forum or all over the Web …

URLDownloadToFile windows function works only for a file
which has its own URL, so is it the case or not ?
 
Element Download_Raw needs to be downloaded.
But the file is not constant it changes as per the dates selection.
 
Back
Top