Run-Time Error '438': Object Doesn't support this property or method (1 Viewer)

Mezta1988

Registered User.
Local time
Today, 05:49
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
 

Frothingslosh

Premier Pale Stale Ale
Local time
Yesterday, 22:49
Joined
Oct 17, 2012
Messages
3,276
It's SelectedItems, not SelectionItems. The error you're receiving means that the provided property name doesn't exist.
 

isladogs

MVP / VIP
Local time
Today, 03:49
Joined
Jan 14, 2017
Messages
18,209
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
 

Mezta1988

Registered User.
Local time
Today, 05:49
Joined
Jan 22, 2019
Messages
41
@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.
 

isladogs

MVP / VIP
Local time
Today, 03:49
Joined
Jan 14, 2017
Messages
18,209
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

Top Bottom