Ciao Joseph,
Chiedo cortesemente di correggere il listato sottostante. L'immagine riesco a selezionarla e poi inserirla nella userform, peccato che la fase di selezione delle immagini ha tempi molto lunghi.
Private Sub CommandButton2_Click()
Dim Selez As Variant
On Error GoTo errHandler
50 Sheets("Foglio1").Visible = xlSheetVisible
52 Sheets("Foglio1").Select
54 With Application.FileDialog(msoFileDialogOpen)
56 .AllowMultiSelect = False
58 .Filters.clear
60 .Filters.Add "Immagini", "*.JPG, *.JPEG,*.BMP, *.GIF"
62 .Show
64 For Each Selez In .SelectedItems
66 cells(10, 9) = Selez
68 Next
70 End With
72 If cells(10, 9) = "" Then
74 Sheets("Foglio1").Visible = xlVeryHidden
76 Exit Sub
78 Else: End If
80 Image1_Click
82 Exit Sub
errHandler:
cells(1, 10) = err.Number & " " & err.Description & " (Frm20-" & Erl & ")"
Call Macro49
End Sub
Priva qualcosa del genere:
Option Explicit
'Public sImmagine As String
Private Sub CommandButton2_Click()
Dim WB As Workbook
Dim SH As Worksheet
Dim FD As FileDialog
Dim sImmagine As String
Const sFoglio As String = "Foglio1"
10 On Error GoTo errHandler
20 Set WB = ThisWorkbook
30 Set SH = WB.Sheets(sFoglio)
40 With SH
50 Sheets("Foglio1").Visible = xlSheetVisible
60 Sheets("Foglio1").Select
70 End With
80 Set FD = Application.FileDialog(msoFileDialogOpen)
90 With FD
100 .AllowMultiSelect = False
110 .Title = "Seleziona Immagine"
120 .Filters.Clear
130 .Filters.Add "Immagini", "*.JPG, *.JPEG,*.BMP, *.GIF"
140 .InitialView = msoFileDialogViewDetails
150 If .Show = True Then
160 sImmagine = .SelectedItems(1)
170 With Me
180 .Img1.Picture = LoadPicture(sImmagine)
190 .Repaint
200 End With
210 Else
220 MsgBox "No"
230 If SH.Cells(10, 9) = "" Then
240 Sheets("Foglio1").Visible = xlVeryHidden
250 Exit Sub
260 End If
270 End If
280 End With
290 SH.Cells(10, 9).Value = sImmagine
XIT:
300 Set FD = Nothing
310 Exit Sub
errHandler:
320 SH.Cells(1, 10) = Err.Number & " " _
& Err.Description _
& " (Frm20-" & Erl & ")"
Call Macro49
End Sub
'<<=========
A me, la selezione delle immagini è praticamente istantanea.
===
Regards,
Norman
