The Attributes line is not used in VBA. Running the routine returned 1 page count for a file with many pages.

You might want to try something like a FreeImage. The code is in vb but doing it in vba should be easy enough. http://www.paulbradley.org/28/