Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Problem with MSINET.OCX: instantiation of New Inet

Hi guys

I need to download files from a static URL and am using the following
code from http://officeone.mvps.org/vba/http_download_file.html:

Sub HTTPDownloadFile(ByVal URL As String, _
ByVal LocalFileName As String)
Dim HTTP As Inet
Dim Contents() As Byte

Set HTTP = New Inet ' <<<< CODE FAILS HERE

With HTTP
.Protocol = icHTTP
.URL = URL
Contents() = .OpenURL(.URL, icByteArray)
End With

Set HTTP = Nothing

Open LocalFileName For Binary Access Write As #1
Put #1, , Contents()
Close #1
End Sub

The code works on some machines but not others, failing at "Set HTTP =
New Inet".

The error message is:
"Run-time error '429':
ActiveX component can't create object".

I can't detect any reason why the code works on one machine and not
the other, as they are allegedly built from the same profile (both
running WinXP, Office2003). Both machines have MSINET.OCX, same
version (6).

I'm thinking maybe it's a registry entry, but hopefully someone on
here has come across this and has a solution?

TIA

Paul Martin
Melbourne, Australia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Problem with MSINET.OCX: instantiation of New Inet

Try using the URLDownloadToFile API function. For example,


Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Sub AAA()
Dim URL As String
Dim DestFile As String
Dim Res As Long

URL = "http://www.cpearson.com/Excel/about.htm"
DestFile = "C:\Test\About.htm"
On Error Resume Next
Kill DestFile
On Error GoTo 0
Res = URLDownloadToFile(0&, URL, DestFile, 0&, 0&)
If Res = 0 Then
Debug.Print "Success"
Else
Debug.Print "Failure"
End If
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Mon, 26 Jan 2009 21:17:00 -0800 (PST), Paul Martin
wrote:

Hi guys

I need to download files from a static URL and am using the following
code from http://officeone.mvps.org/vba/http_download_file.html:

Sub HTTPDownloadFile(ByVal URL As String, _
ByVal LocalFileName As String)
Dim HTTP As Inet
Dim Contents() As Byte

Set HTTP = New Inet ' <<<< CODE FAILS HERE

With HTTP
.Protocol = icHTTP
.URL = URL
Contents() = .OpenURL(.URL, icByteArray)
End With

Set HTTP = Nothing

Open LocalFileName For Binary Access Write As #1
Put #1, , Contents()
Close #1
End Sub

The code works on some machines but not others, failing at "Set HTTP =
New Inet".

The error message is:
"Run-time error '429':
ActiveX component can't create object".

I can't detect any reason why the code works on one machine and not
the other, as they are allegedly built from the same profile (both
running WinXP, Office2003). Both machines have MSINET.OCX, same
version (6).

I'm thinking maybe it's a registry entry, but hopefully someone on
here has come across this and has a solution?

TIA

Paul Martin
Melbourne, Australia

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Problem with MSINET.OCX: instantiation of New Inet

Worked first time; thanks Chip

Paul
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 429 when trying to create Inet object Radu[_2_] Excel Discussion (Misc queries) 0 April 15th 10 02:08 PM
msinet.ocx hs234 Excel Programming 3 July 22nd 04 06:15 PM
msinet.ocx Tom Ogilvy Excel Programming 1 July 21st 04 04:08 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM
Control IE popup from excel VBA instantiation jonathan Excel Programming 0 October 29th 03 09:09 PM


All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"