Download a WMV file "Object required" error

NMadson

New Member
Joined
Jul 11, 2012
Messages
7
I've found umpteen examples of code to download files from the Internet, none of which I can get to work in Excel 2013. I'm trying to get the basic functionality working before I expand my code to do the other things I want to do, so below is the simplest version of code I could find which I thought should work. At the following line

Set objStream = CreateObject(“ADODB.Stream”)

I get an error message "Object required." I must be doing something simple wrong. Can anyone point me in the direction of my error?

TIA,
Nolan
<code>
Sub testDownload()

Dim objStream As Object
Dim xHttp As MSXML2.XMLHttp
Set xHttp = New MSXML2.XMLHttp
xHttp.Open "GET", "http://www.xxxxx.wmv", False
xHttp.send
Set objStream = CreateObject(“ADODB.Stream”)
objStream.Type = 1
objStream.Open
objStream.Write xHttp.responseBody
objStream.SavetoFile "I:\xxxxx.wmv", 2
objStream.Close

End Sub
</code>
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
What is the URL of the wmv file?

Also, can you please use
Code:
 tags when you paste code over here? Thanks.
 
Upvote 0
I noticed that in the offending line your double quotes seem to be incorrect.
Might be worth looking at (next to using
Code:
 tags).
 
Upvote 0
Re:
Code:
 tags; sorry, I thought it was <Code>.  I'll use "[Code]" henceforth.
Re: the URL - sorry, I can't publish the exact details of the process - confidentiality reasons.
Re: quotes, yes, in cutting and pasting I accidentally inserted non-printable left and right double quotes instead of straight double quotes.  That was the issue.

Now the file I download is only the log-in page, not the media file that was my intent.  Passing my user id and password to the site is another problem I was having, but I was trying to address issues one at a time.

Thanks,
Nolan
 
Upvote 0
Hello Nolan

You're welcome !
 
Upvote 0

Forum statistics

Threads
1,216,118
Messages
6,128,939
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top