Connecting Tech Pros Worldwide Forums | Help | Site Map

Determining the size of a file via a URL

Jozef
Guest
 
Posts: n/a
#1: Nov 13 '05
Hello,

I'd like to determine the size of a file via a URL. I'm not even sure how
to do this on the local machine, let alone a URL. Any help would be greatly
appreciated.

Thanks!




john@miesoftware.com
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Determining the size of a file via a URL


Not sure about via a URL but in VBA you can retrieve size with the
FileLen function. E.g.

SizeInBytes = FileLen(Pathname)

rkc
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Determining the size of a file via a URL


Jozef wrote:
[color=blue]
> I'd like to determine the size of a file via a URL. I'm not even sure how
> to do this on the local machine, let alone a URL. Any help would be greatly
> appreciated.[/color]

If you mean you want to know the size of the source file of a web page
you can send request for the http headers only via a Microsoft.XMLHTTP
object and check the value for Content-Length.

In a nutshell:

Dim msXML As Object
Set msXML = CreateObject("Microsoft.XMLHTTP")
msXML.Open "HEAD", url, False
msXML.send
Debug.Print msXML.getResponseHeader("Content-Length")
Set msXML = Nothing
Jozef
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Determining the size of a file via a URL


Excellent! Thanks for your help, that works very well!


"rkc" <rkc@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:VMrqe.3812$g5.512@twister.nyroc.rr.com...[color=blue]
> Jozef wrote:
>[color=green]
>> I'd like to determine the size of a file via a URL. I'm not even sure
>> how
>> to do this on the local machine, let alone a URL. Any help would be
>> greatly
>> appreciated.[/color]
>
> If you mean you want to know the size of the source file of a web page
> you can send request for the http headers only via a Microsoft.XMLHTTP
> object and check the value for Content-Length.
>
> In a nutshell:
>
> Dim msXML As Object
> Set msXML = CreateObject("Microsoft.XMLHTTP")
> msXML.Open "HEAD", url, False
> msXML.send
> Debug.Print msXML.getResponseHeader("Content-Length")
> Set msXML = Nothing[/color]


karl@q2q.us
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Determining the size of a file via a URL


I can't get the following code to run. I have MSXML 4.0 installed but I
can't find a Type library to Reference so when I key in something like
msXML. nothing pops up as a valid choice to enter after the dot.

Do I need something other than MSXML 4.0 and what Name should I look
for when setting the Reference to a Type library?

I'm using A2003
[color=blue]
>
> Dim msXML As Object
> Set msXML = CreateObject("Microsoft.XMLHTTP")
> msXML.Open "HEAD", url, False
> msXML.send
> Debug.Print msXML.getResponseHeader("Content-Length")
> Set msXML = Nothing[/color]

Closed Thread