Run-Time Error '438': Object Doesn't support this property or method

Mezta1988

Registered User.
Local time
Tomorrow, 01:14
Joined
Jan 22, 2019
Messages
41
Hi,

Run-Time Error '438': Object Doesn't support this property or method.

I'm creating a button to upload a picture file but I'm getting the above error code.

Code:
Private Sub CmdAddPhoto_Click()
Dim f As Object
Dim strfile As String
Dim strfolder As String
Dim VarItem As Variant

Set f = Application.FileDialog(3)
f.allowMultiSelect = True
If f.Show Then
For Each VarItem In f.SelectionItems -------------> This where I get an error.
strfile = Dir(VarItem)

strfolder = Left(VarItem, Len(VarItem) - Len(strfile))
MsgBox "Folder" & strfolder & vbCrLf & _
"File: " & strfile

ImagePathControl = strfolder + strfile
Next
End If
Set f = Nothing
End Sub
 
It's SelectedItems, not SelectionItems. The error you're receiving means that the provided property name doesn't exist.
 
Apart from the issue that Frothy picked up, are you SURE you want to use a multiselect listbox? That is intended when you want to select several items from a list
If you just want to upload/attach/use an image file that's NOT what you need
 
@isladog I didn't know that it was meant for multiple selection, I just saw a that on youtube. I tried to follow the codes that you gave me but everytime I solve an error then another error again will come up. by the way what type of frame you use for the "errormsg" which the Photo not available appears.
 
The errormsg object is just a label - as it says throughout the code for the subform

It might have been quicker for you to have just imported each of my forms & the module code then modify one part at a time checking it still works for you
 

Users who are viewing this thread

Back
Top Bottom