> Is there a way to access the header information of a file? I am
> thinking of JPEG and GIF files, where I want to find the horizontal
> and vertical pixel sizes of these and put these pixel sizes into a
> Word table.
Jay,
http://abstractvb.com/code/code677.asp seems to be exactly what you are
looking for (for jpeg files). And http://www.vishwatech.com/c6/v2/C1726.html
lists a function for gif files.
If you are looking for a similar approach for BMP files ... google will
help you ;-)
cheers,
Stephan
Jay - 16 Sep 2005 08:43 GMT
Thanks Stephan,
I had a look at these and have got the jpeg and gif ones working. One
problem is that if the file doesn't exist, it creates a blank file.
I'd prefer to get an error if the file doesn't exist. How do I do
this? Is there a VBA command to check for a file's existence? Here
some example code...
Dim Fnum as integer
Dim Filename as string
Filename = ????
Fnum = FreeFile
Open Filename For Binary As #Fnum
> Jay,
>
[quoted text clipped - 7 lines]
> cheers,
> Stephan
Dr. Stephan Kassanke - 16 Sep 2005 10:29 GMT
> Thanks Stephan,
>
[quoted text clipped - 11 lines]
> Fnum = FreeFile
> Open Filename For Binary As #Fnum
Hi Jay,
here is a file exists function from J Walkenbach.
Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then FileExists = True _
Else FileExists = False
End Function
Check the existence before you try to access the file
if FileExists(FName)= false then
Exit sub
end if
' further code
cheers,
Stephan
Jay - 19 Sep 2005 10:38 GMT
Thanks again Stephen for your kind help.
Dr. Stephan Kassanke - 19 Sep 2005 12:29 GMT
> Thanks again Stephen for your kind help.
you are welcome.
Stephan