Link to home
Start Free TrialLog in
Avatar of gordonwwaugh
gordonwwaughFlag for United States of America

asked on

Get resolution of graphic file using VBA

I want VBA (Visual Basic for applications) within MS Access to get the resolution of a graphic file (i.e., png, gif, bmp, jpeg). By the way, I need the width and height of the graphic because I am generating html code that rescales the graphic to the appropriate size.

Is there a VBA function or windows call that returns this information?
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gordonwwaugh

ASKER

It almost worked. I had to replace "Items.Item" with "ParseName".

However, something weird is happening. It fails if I replace the "c:\users\mark\downloads" with a string variable name. For example, this doesn't work:

strFoldername = "c:\users\mark\downloads"
set objFolder = objShell.NameSpace(strFoldername)

When I use this code, I get the following error on the "set objFile = ..." line: "Object variable not set." I have verified that the strFoldername value is correct.

Any ideas? Surely I am allowed to use a variable name in the "set objFolder" statement rather than a quoted string.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The expert's solution has one error.
I wouldn't assert that my original code post had errors, since it worked for me.  Like you, I didn't know that the Namespace() parameter had to be a Variant data type.  The string literal I used was being automatically cast by the compiler/interpreter.  When working to quickly answer EE questions, I'm often in the Immediate Window where all dynamic variables are variant.
The expert's solution has one error. My solution fixes the error and adds additional supporting code such as variable declarations.