yinkajewole
Active Member
- Joined
- Nov 23, 2018
- Messages
- 281
how can one display the thumbnails of files that are in a listbox especially for .jpg, .cdr?
Private Sub UserForm_Initialize()
ListBox1.AddItem "labels_neg.jpg"
ListBox1.AddItem "charts.gif"
ListBox1.AddItem "times.jpg"
ListBox1.AddItem "barg.jpg"
End Sub
Private Sub UserForm_Click()
Dim c As Control, n%, i%
n = Me.ListBox1.ListCount
For i = 1 To n
Set c = Me.Controls.Add("Forms.image.1", "mImg" & i, True)
c.PictureSizeMode = fmPictureSizeModeStretch
c.Width = Me.Width / n
c.Left = (i - 1) * Me.Width / n
c.Picture = LoadPicture("c:\pub\" & Me.ListBox1.List(i - 1))
Next
End Sub
Something like this:
Code:Private Sub UserForm_Initialize() ListBox1.AddItem "labels_neg.jpg" ListBox1.AddItem "charts.gif" ListBox1.AddItem "times.jpg" ListBox1.AddItem "barg.jpg" End Sub Private Sub UserForm_Click() Dim c As Control, n%, i% n = Me.ListBox1.ListCount For i = 1 To n Set c = Me.Controls.Add("Forms.image.1", "mImg" & i, True) c.PictureSizeMode = fmPictureSizeModeStretch c.Width = Me.Width / n c.Left = (i - 1) * Me.Width / n c.Picture = LoadPicture("c:\pub\" & Me.ListBox1.List(i - 1)) Next End Sub
' regular module
Public s$
Sub ThumbNail()
Dim pdfobj
s = "c:\pub\MyPicsat.jpg" ' save to disk with this path
Set pdfobj = ActiveSheet.OLEObjects.Add(Filename:="c:\pub\gt.pdf", link:=True, displayasicon:=False)
pdfobj.Copy
ActiveSheet.PasteSpecial Format:="Imagem (PNG)", link:=False, displayasicon:=False
ExportPic
End Sub
Sub ExportPic()
Dim MyChart$, MyPicture$, PicWidth As Long, PicHeight&, sname$
Application.ScreenUpdating = False
MyPicture = Selection.Name
sname = ActiveSheet.Name
With Selection
PicHeight = .ShapeRange.Height
PicWidth = .ShapeRange.Width
End With
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:=sname
Selection.Border.LineStyle = 0
MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)
With ActiveSheet
With .Shapes(MyChart)
.Width = PicWidth
.Height = PicHeight
End With
.Shapes(MyPicture).Copy
With ActiveChart
.ChartArea.Select
.Paste
End With
.ChartObjects(1).Chart.Export Filename:=s, FilterName:="jpg"
.Shapes(MyChart).Cut
End With
Application.ScreenUpdating = True
End Sub
' user form module
Private Sub UserForm_Click()
Dim c As Control
Me.Caption = "PDF Thumbnail"
ThumbNail
Set c = Me.Controls.Add("Forms.image.1", "mImg1", True)
c.PictureSizeMode = fmPictureSizeModeStretch
c.Width = Me.Width * 0.95
c.Left = 10
c.Height = Me.Height * 0.95
c.Picture = LoadPicture(s)
End Sub