Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Accessing a file header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jay - 13 Sep 2005 16:17 GMT
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.
Dr. Stephan Kassanke - 13 Sep 2005 17:28 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.