Get image dimensions from file on disk and resize picture object to match

James Steinbacher
James Steinbacher used Ask the Experts™
on
First, I'm in waaaaay over my head on this, but I've got to get it working anyway, so...

I need to be able to read the dimensions of an image on disk and then resize the picture object on a Form (or in a Report).  I've tried to research this but like I said, I'm in way over my head.  The two resources that looked the most promising to me are:
https://www.experts-exchange.com/questions/28698115/How-to-get-and-write-the-dimensions-of-images-on-hard-drive-into-an-Access-table.html
https://stackoverflow.com/questions/32465445/microsoft-access-vba-determining-image-dimensions

I chose to try the stackoverflow idea first.  I've got the following code in a Class Module named "ImageDimensions":
Option Explicit

Private pPixelWidth As Long
Private pPixelHeight As Long
Private pImageFullPath As String

Public Property Get ImageFullPath() As String
  ImageFullPath = pImageFullPath
End Property
Public Property Let ImageFullPath(fullPath As String)
  pImageFullPath = fullPath
  Dim dimensionsText As String

  dimensionsText = GetImageDimensions(fullPath)
  pPixelWidth = Left$(dimensionsText, InStr(dimensionsText, ",") - 1)
  pPixelHeight = Mid$(dimensionsText, InStr(dimensionsText, ",") + 1)
End Property

Public Property Get PixelWidth() As Long
  PixelWidth = pPixelWidth
End Property
Private Property Let PixelWidth(value As Long)
  pPixelWidth = value
End Property

Public Property Get PixelHeight() As Long
  PixelHeight = pPixelHeight
End Property
Private Property Let PixelHeight(value As Long)
  pPixelHeight = value
End Property

Private Function GetImageDimensions(ByVal fullPath As String)
  Dim fileName As String
  Dim fileFolder As String
  fileName = FilenameFromPath(fullPath)
  fileFolder = FolderFromFilePath(fullPath)

  Dim objShell As Object
  Set objShell = CreateObject("Shell.Application")

  Dim targetFolder As Object
  Set targetFolder = objShell.Namespace(fileFolder & vbNullString)

  Const IMAGE_DIMENSIONS As Long = 31
  Dim dimensionsPrep As String
  dimensionsPrep = targetFolder.GetDetailsOf( _
    targetFolder.Items.Item(fileName & vbNullString), _
    IMAGE_DIMENSIONS)

  dimensionsPrep = Replace(dimensionsPrep, " x ", ",")
  dimensionsPrep = Mid$(dimensionsPrep, 2, Len(dimensionsPrep) - 2)
  GetImageDimensions = dimensionsPrep
End Function

Private Function FolderFromFilePath(ByVal filePath As String) As String
  Dim filesystem As Object
  Set filesystem = CreateObject("Scripting.FileSystemObject")
  FolderFromFilePath = filesystem.GetParentFolderName(filePath) & "\"
End Function

Private Function FilenameFromPath(ByVal filePathAndName As String) As String
  Dim pathLength As Long
  Dim iString As String
  pathLength = Len(filePathAndName)
  iString = vbNullString

  Dim iCount As Long
  For iCount = pathLength To 1 Step -1
    If Mid$(filePathAndName, iCount, 1) = Application.PathSeparator Then
      FilenameFromPath = iString
      Exit Function
    End If
    iString = Mid$(filePathAndName, iCount, 1) & iString
  Next iCount

  FilenameFromPath = filePathAndName
End Function

Open in new window

According to the author, I need to use that class by putting the following code in a "regular code module":
Sub ExampleImageDimensions()
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  targetImage = "C:\Users\ChrisB\Downloads\Screenshot.jpg"
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window

So, I added the following to my Form:
Private Sub Form_Open(Cancel As Integer)
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  targetImage.ImageFullPath = [TempVars]![ImagePath] & [ImageName]
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window


I'm getting the following error:
"Compile error: Method or data member not found" in reference to:
Error_pathseparator.PNGI do not believe there is any need to call the "FilenameFromPath" function as I am passing the full path to the class module as targetImage.  Unfortunately, I'm not sure how to properly modify the GetImageDimensions function to use the path I'm sending it:
stufftoedit.PNGI tried modifying the GetImageDimensions function as follows:
Private Function GetImageDimensions(ByVal fullPath As String)
  Dim fileName As String
  Dim fileFolder As String
'  fileName = FilenameFromPath(fullPath)
'  fileFolder = FolderFromFilePath(fullPath)

  Dim objShell As Object
  Set objShell = CreateObject("Shell.Application")

'  Dim targetFolder As Object
'  Set targetFolder = objShell.Namespace(fileFolder & vbNullString)
  Dim targetFolder As Object
  Set targetFolder = objShell.Namespace(fullPath)

  Const IMAGE_DIMENSIONS As Long = 31
  Dim dimensionsPrep As String
'  dimensionsPrep = targetFolder.GetDetailsOf( _
'    targetFolder.Items.Item(fileName & vbNullString), _
'    IMAGE_DIMENSIONS)
  dimensionsPrep = targetFolder.GetDetailsOf()
    
  dimensionsPrep = Replace(dimensionsPrep, " x ", ",")
  dimensionsPrep = Mid$(dimensionsPrep, 2, Len(dimensionsPrep) - 2)
  GetImageDimensions = dimensionsPrep
End Function

Open in new window

This yields the following error:
error_91.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
1. Yes, you could put the code in your second snippet into the OnClick event of a form or control.

2. Are ImagePath and ImageName both in the TempVars collection? Of is just ImagePath in the Tempvars collection? If ImagePath is in Tempvars, and ImageName is on the form, then your syntax should be okay (although you may not need the square brackets). If both are in tempvars:

Tempvars!ImagePath & "\" & Tempvars!ImageName

If not, you'll have to tell us where those values reside.

3. You can set the size of a control on your form by using the Height and Width properties of that control, so you could do this:

Me.YourPictureObject.Height = targetImage.PixelHeight
Me.YourPictureObject.Width = targetImage.PixelWidth

I'm not sure if the two values are using the same "dimensions", however - for example, the Height and Width may be in Twips, and the PixelHeight and PixelWidth may be in Pixels. If so, you'd have to determine the types for each and find the correct multipliers to get the dimensions correct.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Why not set the picture control on the form to do the hard work by setting it to: Zoom.
Zero code.

Author

Commented:
Gustav -- I have the picture control set to Zoom and it looks like the attached image, which is really ugly.
JarTestSampleDetails.PNG
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

John TsioumprisSoftware & Systems Engineer

Commented:
The code you have is just to get the size of the Image ...there isn't any manipulation..
In order to manipulate the image..resize ..one way is to use the WIA..
Check this article here
EDIT: Judging by the screenshot you don't actually need to resize the Image Control or the Image...you just need to crop the picture ...cropping out the blank (if this is the case)..otherwise as Gustav said you just need to set the Image Control --> Size Mode -->Zoom

Author

Commented:
Scott,

  1. Will anything break if I put the code into the Form OnOpen event?  I don't want to have to click anything to make it run.
  2. ImageName is coming from a field on my Form.  

Thanks!

Author

Commented:
John -- It looks like the article you linked was for resizing the images on disk.  If so, I don't need to do that.  I'm just trying to get the picture placeholder to resize per the image it is displaying.  See attached.
JarTestSampleDetails.PNG
John TsioumprisSoftware & Systems Engineer

Commented:
I added to my previous comment...probably you need crop
John TsioumprisSoftware & Systems Engineer

Commented:
Well it seems that WIA can also handle this but the reference i found was in French...check here and search for Crop.

Author

Commented:
John -- Cropping the picture would work if the dimensions of possible images that could appear on the form were consistent.  They are not.  Also, I eventually need to put the images into a subreport that will auto-scale the Detail Section as the image size and proportions change.  So, the "extra" work I'm doing on this form will hopefully be helpful when it comes to getting the report to look right.
John TsioumprisSoftware & Systems Engineer

Commented:
Well if it means finding out the blank space of the image this would be tricky ...otherwise the ratio and a default size should be sufficient.

Author

Commented:
I think I see where I've confused everyone.  My mistake.

I want to determine image dimensions -- say: 1000 x 2000.

Then I want to display them in an identically scaled picture object, only at a smaller size (object set to Zoom) -- such as 100 x 200.

So, if an image is 1000 x 2000, it would appear in a 100 x 200 picture object.  If the image is 2000 x 1000, it would appear in a 200 x 100 picture object.  

And I get the pixels vs. TWIPs thing.  Will have to figure that scaling out as I go...

Last, but not least, the blank space I want to get rid of (shown in the attached file) is extra space in the image object.  The picture is Zoomed so that the vertical dimension fits within the image object but the image is taller than it is wide so there is a ton of white space off to the left.  I hope that makes sense...?
JarTestSampleDetails.PNG

Author

Commented:
I placed the following code in the OnOpen event of my form:
Private Sub Form_Open(Cancel As Integer)
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  targetImage = [TempVars]![ImagePath] & [ImageName]
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window

I am getting an error on line 4: "Run-time error 438: 'Object doesn't support this property or method'.
I suspect that this is because ImageName is coming from a field on the form that isn't available at the time the Form opens...?  Or maybe I'm using improper syntax?

Note: TempVars is coming from a module that executes at db startup:
Option Compare Database
Option Explicit
Public Function StartUp()
    Dim sPath                 As String
    sPath = Nz(DLookup("Contents", "GlobalVars", "Variable='ImagesPath'"))
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
    TempVars.Add "ImagePath", sPath
End Function

Open in new window

Most Valuable Expert 2012
Top Expert 2014

Commented:
1.    Will anything break if I put the code into the Form OnOpen event?  I don't want to have to click anything to make it run.

I'd put it in the Current event of the form. That fires each time you move to a different record

2. Then I would think it would be TempVars!ImagePath & Me.ImageName. Of course, you'd have to make sure it's properly formed, with the backslashes and such. You may need something like TempVars!ImagePath & "\" &  Me.ImageName.

Author

Commented:
Scott,

I moved the code to the Current event, as you suggested, and have modified the path concatenation line but am still getting the error.  The values being returned from the variables are displayed at the bottom of this image.  You can see that the "\" is already included with TempVars, so it should be a clean concatenation.  Any ideas?
JarTestSampleDetails2.PNG
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Well, here's the zero code  solution …

Set the properties BackgroundType and BorderType to: Transparent.
Even the, the picture will still have a tiny border - as in this example:

eeflag2.png
from my article Show pictures directly from URLs in Access forms and reports

The title picture on that article also demonstrates this.
John TsioumprisSoftware & Systems Engineer

Commented:
As i said before..i understood you just right...you got an Image with some considerable blank space...you want to crop that image so that it gets only only the part that has meaning...
As Gustav said the easy solution is to have the Image Control have the same color as the rest of the form and because you have blank ...you need Every Backrgound white...your image will be scaled automatically ...it will fit the Image Control and it would look just fine...
Take a look at my attachment along with the pic i used.
The hard solution is what i mentioned about the usage WIA...the tricky part would be to find out where to crop..unless for some reason all your images have a pretty much the same blank space...e.g. 40% right of the valuable content
If not you need to convert the Image to ByteArray and by examining a few rows to find out where the values of white are continuous for a predefined threshold...its a bit of work
e.g....when you convert to array you will get something (for depiction only)
127 23 21  253 255 255 255 255
117 13 121 53 255 255 255 255
137 20 21  253 255 255 255 255
107 23 21  253 255 255 255 255
97 123 201 53 250 255 255 255
127 23 21  253 255 255 255 255
An similar.....
you need to scan the above rows to check where you have a large continuous amount of pixels with white color...(in this case i have 255 for depiction)
So you find out that out of the 8 pixels wide of the image there is a continuance of 3 pixels  with white so you crop to Image 8x6 = 5x6
EDIT: here is a  solution in .NET that kind of implements the above....(it takes a bit different approach as it scans all the pixels and construct a cropping rectangle but the base idea is pretty much the same)
Database14.accdb
Chain256.jpg

Author

Commented:
First of all, thank you to everyone who has been trying to assist.  I don't think I've done a great job explaining what I'm trying to do, so I'll try again...

Gustav is correct in that, for this particular form, making the background and border transparent will produce acceptable results.  

However, I am trying to learn how to programmatically resize the picture object so that I can deal with a variety of issues. For example, I hope to be getting the reports for my application built next week and will run into situations like the one in this mock-up:
Subreport Mock-upWhat I am dealing with now is the following error when my Form is opened:
Error TextThe code is fired by the Current event of the Form and errors at this line:
Error Line
Here is the data returned on the Form for TempVars and ImageName:
Returned Values
I suspect that ImageName is not available the first time the code fires, but I'm just guessing.

I need to understand why the error is happening and what to do to fix it.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Well, TargetImage is defined as a type ImageDimensions.

I don't see any code that defines that type, but I'm guessing that you have defined that object somewhere with a Type statement, and that you might have a FileName property in that type, you might try something like:

TargetImage.FileName = Tempvars!ImagePath & me.ImageName

Author

Commented:
Dale,

ImageDimensions is the name of this Class Module  (which I clearly did not create):
Option Explicit

Private pPixelWidth As Long
Private pPixelHeight As Long
Private pImageFullPath As String

Public Property Get ImageFullPath() As String
  ImageFullPath = pImageFullPath
End Property
Public Property Let ImageFullPath(fullPath As String)
  pImageFullPath = fullPath
  Dim dimensionsText As String

  dimensionsText = GetImageDimensions(fullPath)
  pPixelWidth = Left$(dimensionsText, InStr(dimensionsText, ",") - 1)
  pPixelHeight = Mid$(dimensionsText, InStr(dimensionsText, ",") + 1)
End Property

Public Property Get PixelWidth() As Long
  PixelWidth = pPixelWidth
End Property
Private Property Let PixelWidth(value As Long)
  pPixelWidth = value
End Property

Public Property Get PixelHeight() As Long
  PixelHeight = pPixelHeight
End Property
Private Property Let PixelHeight(value As Long)
  pPixelHeight = value
End Property

Private Function GetImageDimensions(ByVal fullPath As String)
  Dim fileName As String
  Dim fileFolder As String
  fileName = FilenameFromPath(fullPath)
  fileFolder = FolderFromFilePath(fullPath)

  Dim objShell As Object
  Set objShell = CreateObject("Shell.Application")

  Dim targetFolder As Object
  Set targetFolder = objShell.Namespace(fileFolder & vbNullString)

  Const IMAGE_DIMENSIONS As Long = 31
  Dim dimensionsPrep As String
  dimensionsPrep = targetFolder.GetDetailsOf( _
    targetFolder.Items.Item(fileName & vbNullString), _
    IMAGE_DIMENSIONS)

  dimensionsPrep = Replace(dimensionsPrep, " x ", ",")
  dimensionsPrep = Mid$(dimensionsPrep, 2, Len(dimensionsPrep) - 2)
  GetImageDimensions = dimensionsPrep
End Function

Private Function FolderFromFilePath(ByVal filePath As String) As String
  Dim filesystem As Object
  Set filesystem = CreateObject("Scripting.FileSystemObject")
  FolderFromFilePath = filesystem.GetParentFolderName(filePath) & "\"
End Function

Private Function FilenameFromPath(ByVal filePathAndName As String) As String
  Dim pathLength As Long
  Dim iString As String
  pathLength = Len(filePathAndName)
  iString = vbNullString

  Dim iCount As Long
  For iCount = pathLength To 1 Step -1
    If Mid$(filePathAndName, iCount, 1) = Application.PathSeparator Then
      FilenameFromPath = iString
      Exit Function
    End If
    iString = Mid$(filePathAndName, iCount, 1) & iString
  Next iCount

  FilenameFromPath = filePathAndName
End Function

Open in new window

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
I don't use class modules much, but that class has a property:  ImageFullPath

So maybe you need to set that classes ImageFullPath property to the path and file name you mentioned,

Author

Commented:
Dale,

I thought that the line that is causing the error is the one that is supposed to pass the path to the Class...
Concat_Error.PNGConcat_Values.png
This is what the original code author had in that line:
 
targetImage = "C:\Users\ChrisB\Downloads\Screenshot.jpg"

Open in new window

Most Valuable Expert 2012
Top Expert 2014

Commented:
I'd suggest you place a breakpoint on that line and then see what the values of those two items are. To do that, when you run the code and hit the breakpoint, type this in the Immediate window:

?TempVars!ImagePath

And press Enter. You should see the value stored in ImagePath. Do the same for this one:

?Me.ImageName

Author

Commented:
Scott -- Thank you for those super-clear instructions.  Understanding how to troubleshoot in the environment makes a huge difference.  I can't wait to take some MSAccess courses now that I'm an EE member!

Anyway, here are the results:

?TempVars!ImagePath
\\192.168.1.4\wmops\WMcit\dbImages\

?Me.ImageName
1130161813a.jpg

It looks to me like the values are correct.  Cause of the error still a mystery.
As I can see there is small error in sample. Try to set ImageFullPath property:
Private Sub Form_Open(Cancel As Integer)
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  targetImage.ImageFullPath = [TempVars]![ImagePath] & [ImageName]
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window

Author

Commented:
als315 -- You got me closer to the solution!  Now I'm getting a different error -- in the class module:

"Compile error: Method or data member not found" in reference to:
Error_pathseparator.PNG
The class module code can be found in the OP.   I do not believe there is any need to call the "FilenameFromPath" as I am passing the full path to the class module as targetImage.  I'm not sure how to properly modify the GetImageDimensions function to use the path I'm sending it.
stufftoedit.PNG

I tried modifying the GetImageDimensions function as follows:
Private Function GetImageDimensions(ByVal fullPath As String)
  Dim fileName As String
  Dim fileFolder As String
'  fileName = FilenameFromPath(fullPath)
'  fileFolder = FolderFromFilePath(fullPath)

  Dim objShell As Object
  Set objShell = CreateObject("Shell.Application")

'  Dim targetFolder As Object
'  Set targetFolder = objShell.Namespace(fileFolder & vbNullString)
  Dim targetFolder As Object
  Set targetFolder = objShell.Namespace(fullPath)

  Const IMAGE_DIMENSIONS As Long = 31
  Dim dimensionsPrep As String
'  dimensionsPrep = targetFolder.GetDetailsOf( _
'    targetFolder.Items.Item(fileName & vbNullString), _
'    IMAGE_DIMENSIONS)
  dimensionsPrep = targetFolder.GetDetailsOf()
    
  dimensionsPrep = Replace(dimensionsPrep, " x ", ",")
  dimensionsPrep = Mid$(dimensionsPrep, 2, Len(dimensionsPrep) - 2)
  GetImageDimensions = dimensionsPrep
End Function

Open in new window

This yields the following error:
error_91.PNG
Change Application.PathSeparator to "\".
Don't modify class module. You can get image dimensions with existing code
John TsioumprisSoftware & Systems Engineer

Commented:
The code you are using would be work just fine in older versions of Office but according to this post it seems is deprecated...the whole code was depending on an extension Shell Metadata Handler which was removed after June 2016..that's why you get errors..
Normally the targetfolder would hold the info you are after ...but now because it can't communicate its returns nothing..so the whole code goes kaput.
So you either go with the EE solution (WIA)...preferred.....or
there seems to be another way using Windows API from EverythingAccess
@John Tsioumpris: code is working (Tested in windows 10 and office2010 and 2016).
Private Sub test()
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  'targetImage.ImageFullPath = [TempVars]![ImagePath] & [ImageName]
  
  'Path to any image file
  targetImage.ImageFullPath = "e:\TMP\inv.jpg"
  
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window

Class module (ImageDimensions):
Option Explicit

Private pPixelWidth As Long
Private pPixelHeight As Long
Private pImageFullPath As String

Public Property Get ImageFullPath() As String
  ImageFullPath = pImageFullPath
End Property
Public Property Let ImageFullPath(fullPath As String)
  pImageFullPath = fullPath
  Dim dimensionsText As String

  dimensionsText = GetImageDimensions(fullPath)
  pPixelWidth = Left$(dimensionsText, InStr(dimensionsText, ",") - 1)
  pPixelHeight = Mid$(dimensionsText, InStr(dimensionsText, ",") + 1)
End Property

Public Property Get PixelWidth() As Long
  PixelWidth = pPixelWidth
End Property
Private Property Let PixelWidth(value As Long)
  pPixelWidth = value
End Property

Public Property Get PixelHeight() As Long
  PixelHeight = pPixelHeight
End Property
Private Property Let PixelHeight(value As Long)
  pPixelHeight = value
End Property

Private Function GetImageDimensions(ByVal fullPath As String)
  Dim fileName As String
  Dim fileFolder As String
  fileName = FilenameFromPath(fullPath)
  fileFolder = FolderFromFilePath(fullPath)

  Dim objShell As Object
  Set objShell = CreateObject("Shell.Application")

  Dim targetFolder As Object
  Set targetFolder = objShell.Namespace(fileFolder & vbNullString)

  Const IMAGE_DIMENSIONS As Long = 31
  Dim dimensionsPrep As String
  dimensionsPrep = targetFolder.GetDetailsOf( _
    targetFolder.Items.Item(fileName & vbNullString), _
    IMAGE_DIMENSIONS)

  dimensionsPrep = Replace(dimensionsPrep, " x ", ",")
  dimensionsPrep = Mid$(dimensionsPrep, 2, Len(dimensionsPrep) - 2)
  GetImageDimensions = dimensionsPrep
End Function

Private Function FolderFromFilePath(ByVal filePath As String) As String
  Dim filesystem As Object
  Set filesystem = CreateObject("Scripting.FileSystemObject")
  FolderFromFilePath = filesystem.GetParentFolderName(filePath) & "\"
End Function

Private Function FilenameFromPath(ByVal filePathAndName As String) As String
  Dim pathLength As Long
  Dim iString As String
  pathLength = Len(filePathAndName)
  iString = vbNullString

  Dim iCount As Long
  For iCount = pathLength To 1 Step -1
    If Mid$(filePathAndName, iCount, 1) = "\" Then
      FilenameFromPath = iString
      Exit Function
    End If
    iString = Mid$(filePathAndName, iCount, 1) & iString
  Next iCount

  FilenameFromPath = filePathAndName
End Function

Open in new window

Author

Commented:
als315

I have replaced the entire class module code in my project with the code from your post, just to make sure nothing was missed.  I am getting the following error at line 6 of the Form event code:
error_91.PNG
Private Sub Form_Current()
  Dim targetImage As ImageDimensions
  Set targetImage = New ImageDimensions
  
'  targetImage.ImageFullPath = [TempVars]![ImagePath] & [ImageName]
    targetImage.ImageFullPath = "c:\TestImage.jpg"
    
  Debug.Print targetImage.PixelHeight
  Debug.Print targetImage.PixelWidth
End Sub

Open in new window

What is your Access version?
Later today I'll prepare sample DB

results from excel 2010:
sample

Author

Commented:
@John Tsioumpris -- I read the article you posted about the deprecation of the "Shell Metadata Handler."  If I understand correctly, the problem is here:
    dimensionsPrep = targetFolder.GetDetailsOf( _
    targetFolder.Items.Item(fileName & vbNullString), _
    IMAGE_DIMENSIONS)

I then went searching for the code you refer to as the "EE solution (WIA)...preferred" and believe it is here.

I'm currently going over the code and don't know what to do about these lines:
'need a reference to the MS Office Objects XX.0 (11.0 12.0, 14.0 whichever) library
'need a reference to MS Windows Image Acquisition 2.0 library

Open in new window

What does such a reference look like and where does it get placed?

Continuing to read and try to wrap my head around the article...

Author

Commented:
@als315 -- I am using Access 2019, version 1808.
John TsioumprisSoftware & Systems Engineer

Commented:
That's the easy part...
As you are in the Visual Basic Editor go to the menu Bar ...Tools-->References...scroll up and down and you should find th References
See some pics ( i am on higher version -- Access 2019 but it would pretty much the same)
Clipboard01.jpgClipboard02.jpgClipboard03.jpgClipboard04.jpg

Author

Commented:
@John Tsioumpris -- thanks for the reference info.  I am so out of my depth here.  That's one of the reasons I didn't immediately dive into the solution you recommended much earlier in this thread.  Specifically, I've been avoiding the solution because of these "caveats" listed by the original author:

  1. The attached sample is NOT intended to be changed into production code.  I haven't built any error handling or validation code.
  2. The variables you put into the form are not checked for sanity.

I don't have the first clue how to address these issues, which seem significant.  Am I overreacting?
John TsioumprisSoftware & Systems Engineer

Commented:
You just have to take a step at the time...take a look back on all the info we have provided...read--test-read-try the code that is available and when you have moved a bit forward come back .
OK, I've got same error in Access. Look at sample with modified class module
GetImageSize.accdb

Author

Commented:
Thank you to everyone who helped me with this!  I don't get outside of PLC programming much, and working with those languages doesn't do much to prepare one for higher level languages.  You've all forgotten more about VB programming than I'll ever know and your patience is greatly appreciated.

A huge thank you goes to als315 for the reworking of the class module, as well as figuring out the proper formatting of the path variables!  

I had no idea this was going to be such a headache, but the results will be used in multiple Forms and Reports throughout my application, so thank you again!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial