PDA

View Full Version : Image viewer with images control



GhostofDoom
01-17-2020, 03:34 PM
Hello,

how can we make an image viewer
with in a frame1 and image controls

we like to go from out our database access to load where the ID from the person
and get all his image URLs and add them into the frame1 and create the image controls

like this image i created

Thanks25829

GhostofDoom
01-18-2020, 09:10 AM
Hello,

how can i add an image in every msforms.image
when we use imagepath with every time a other location/file




Private imgLts(20) As MSForms.Image
Dim strInPath As String
Dim strOutPath As String
strOutPath = ThisWorkbook.Path & "\some.jpg" 'sample will be replace with other images in a loop






here we like to replace all the images with a picture from the strOutPath
but it only insert in all image with same file




For i = 1 To 1
For j = 1 To 7
k = i + (1 * j)
Set imgLts(k) = Frame2.Controls.Add("Forms.Image.1", "cmd1")
With imgLts(k)
.Top = i * 6
.Left = (j * 50) - 55 + 12
.Height = 54
.Width = 48
.Picture = LoadPicture(strOutPath)
.PictureSizeMode = fmPictureSizeModeZoom
End With
Next j
Next i

GhostofDoom
01-19-2020, 10:17 PM
i have tried to get all items from the listbox and works



For IntIndex = 0 To .ListCount - 1
LoadingImages (.Column(5, IntIndex))
Next
End With


but i can't manage to add seperate images ?
i get in the pictures the same one



Sub LoadingImages(m_url As String)
Dim imageurl As String
Dim fileName As String

imageurl = m_url
fileName = Environ("temp") & "" & Mid(imageurl, InStrRev(imageurl, "/") + 1)



' size of thumbnail
Dim lngSide As Long
lngSide = 50




Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets.Add


Dim cht As Chart
Set cht = ws.Shapes.AddChart(xlColumnClustered, _
Width:=lngSide, _
Height:=lngSide).Chart


Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True


For i = 1 To 1
For j = 1 To 1
k = i + (1 * j)
Set cmdLots(k) = Frame2.Controls.Add("Forms.Image.1", "cmd1")
With cmdLots(k)
.Top = i * 6
.Left = (j * 50) - 55 + 12
.Height = 54
.Width = 48
.BackColor = RGB(50, 50, 0)
.Picture = LoadPicture(fileName) 'get same one ????
.PictureSizeMode = fmPictureSizeModeZoom
End With
Next j
Next i




anyone please

-Thank you

GhostofDoom
01-20-2020, 12:15 PM
i tried it this way now
and still replace all the image :(

what are we missing??



LoadingImages .Column(5, intindex), intindex + 1




Sub LoadingImages(m_url As String, m_index As Integer)
Dim imageurl As String
Dim fileName As String




imageurl = m_url
fileName = Environ("temp") & "" & Mid(imageurl, InStrRev(imageurl, "/") + 1)



' size of thumbnail
Dim lngSide As Long
lngSide = 50


Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets.Add




Dim cht As Chart
Set cht = ws.Shapes.AddChart(xlColumnClustered, _
Width:=lngSide, _
Height:=lngSide).Chart




Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True



For i = 1 To 1
For j = 1 To m_index
k = i + (1 * j)
Set cmdLots(k) = Frame2.Controls.Add("Forms.Image.1", "cmd" & m_index)
With cmdLots(k)
.Top = i * 6
.Left = (j * 50) - 55 + 12
.Height = 54
.Width = 48
.BackColor = RGB(50, 50, 0)
.PictureSizeMode = fmPictureSizeModeZoom
.Picture = Nothing
End With


Next j
Next i



For Each ctrl In Frame2.Controls
' MsgBox (ctrl.name) 'i used this and seems it show cmd1 cmd1 cmd1 cmd 2 cmd 2 cmd2 cmd3 cmd3 cmd3
'so i guess that's way it replace them....
'but how to fix it please


If TypeName(ctrl) = "Image" Then


If ctrl.name = "cmd1" Then
ctrl.Picture = LoadPicture(fileName)
Exit Sub
End If
End If
Next ctrl
End If

End Sub

GhostofDoom
01-20-2020, 07:40 PM
i have made a sample with the access database where the images are stored

hope someone can helpme now

thank you