I'm trying to get the height of a bitmap by using the Shell object in VBA. Here is the relevant portion of code (bmp
is a member of a custom class, and .Width
is a property defined as an Integer.)
Set objImg = objShell.Namespace(subfs(sf)).ParseName(bmp.Name)
tmpDim = objShell.Namespace(subfs(sf)).GetDetailsOf(objImg, 162)
tmpDim = Replace(tmpDim, "?", "")
tmpDim = Replace(tmpDim, " pixels", "")
bmp.Width = CInt(tmpDim)
I'm getting a Type Mismatch error on the last line because the value of tmpDim is ?754
. For reference, the value of tmpDim after the second line is ?754 pixels
.
I have a step included to replace the ?
with an empty string, but it clearly does not work. This is driving me nuts. Does anyone know why this is happening and how to get around this problem?