RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Good day,
I have a userform with 31 image controls (on for each day of the month of May) which populate with pictures from a folder that are all contain dates (again in May) in the name. I then extract the date from the filename and find the correct image control to place it in. The code works until I try to upload the picture into the image control - throws the error "Compile Error: Wrong number of arguments or invalid property assignment" - not sure what the problem is.
I have a userform with 31 image controls (on for each day of the month of May) which populate with pictures from a folder that are all contain dates (again in May) in the name. I then extract the date from the filename and find the correct image control to place it in. The code works until I try to upload the picture into the image control - throws the error "Compile Error: Wrong number of arguments or invalid property assignment" - not sure what the problem is.
Code:
Private Sub LoadPicture()
Dim FileSys As FileSystemObject
Dim myFolder
Dim strFilename As String
Dim objFile As File
Dim PicDay As Long
'set path for files
Const myDir As String = "[URL="file://\\netapp6\tempstor\John"]\\netapp6\tempstor\John[/URL] Halfyard\Nickel Pictures\GIMP"
'set up filesys objects
Set FileSys = New FileSystemObject
Set myFolder = FileSys.GetFolder(myDir)
'go through tempstor and cycle through pictures
For Each objFile In myFolder.Files
PicDay = Mid(objFile.Name, 15, 2) 'this returns the day of the month
'each image control is labelled "Month1, Month2, Month3, etc)
Me.Controls("Month" & PicDay).Picture = LoadPicture(myDir & Application.PathSeparator & objFile.Name)
Next objFile
Set FileSys = Nothing
Set myFolder = Nothing
End Sub