Private Sub cmdArchivio_Click()
Dim f As FileDialog, b As Boolean
Set f = Application.FileDialog(msoFileDialogFilePicker)
If f.Show = False Then Exit Sub
Me.txtPercorso = f.SelectedItems(1)
Sheets("Foglio10").[a1] = Me.txtPercorso
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim nfile As String
nfile = Cells(ListBox1.ListIndex + 6, 8)
On Error GoTo controllo
Workbooks.Open Me.txtPercorso & "" & nfile
Unload Me
Exit Sub
controllo:
Call MsgBox("Il file non esiste più oppure la cartella di ricerca è sbagliata" _
& vbCrLf & "cerca il percorso dove risiede il file" _
, vbExclamation, "errore")
Me.cmdArchivio.Enabled = True
Me.cmdArchivio.SetFocus
End Sub
Private Sub UserForm_Activate()
Dim ur As Integer, i As Integer
ur = Foglio1.Cells(Rows.Count, 1).End(xlUp).Row
With Me.ListBox1
.ColumnCount = 8
.ColumnWidths = "40;60;50;60;50;50;50;50"
For i = 6 To ur
.AddItem Cells(i, 1)
.List(i - 6, 1) = Cells(i, 2)
.List(i - 6, 2) = Cells(i, 3)
.List(i - 6, 3) = Cells(i, 4)
.List(i - 6, 4) = Cells(i, 5)
.List(i - 6, 5) = Cells(i, 6)
.List(i - 6, 6) = Cells(i, 7)
.List(i - 6, 7) = Cells(i, 8)
Next i
End With
Me.txtPercorso = Sheets("Foglio10").[a1]
End Sub
|