Save a pdf file when opened in a browser object

A

And

I use shdocvw InternetExplorer Object to open a pdf file and then I
want to automatically save it but the web site from wich I'm
downloading the file doesn't allows to save the file using the
webrequest command so my idea is to save it using the save command from
the internet explorer but it still doen't work!

The code I am using is the following:

Private Sub BtnSave_Click()
Dim eQuery As OLECMDID
Dim bb As Object
bb = CreateObject("InternetExplorer.Application")
bb.navigate("http://somedomain.com/file.pdf")
bb.visible = True
Do While (bb.busy Or bb.readystate <> 4)
System.Threading.Thread.Sleep(50)
Loop

On Error Resume Next
eQuery = bb.QueryStatusWB(SHDocVw.OLECMDID.OLECMDID_SAVE)
If Err.Number = 0 Then
If eQuery And SHDocVw.OLECMDF.OLECMDF_ENABLED Then
bb.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVE,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, "", "")
Else
MsgBox("The Print command is currently disabled.")
End If
End If
If Err.Number <> 0 Then MsgBox("Print command Error: " &
Err.Description)

End Sub


The code works just fine with html pages (changing
SHDocVw.OLECMDID.OLECMDID_SAVE to SHDocVw.OLECMDID.OLECMDID_SAVEAS) but
it doesn't work when ie is displaying a pdf file.

Can anyone help me

Tks in advance

And
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top