'' # SubRoutine per l' apertura dei disegni
Private Sub CmdApriDisegni_Click()
Dim NomeFile As String
Dim X
X = TextBox12.Text
If TextBox12 = "" Then
MsgBox "La cella del codice DISEGNO è vuota"
Exit Sub
End If
'' Assegnazione alla variabile "fs" del metodo di ricerca
Set fs = Application.FileSearch
'' Con la variabile "fs"
With fs
'' Cerca nel percorso dei disegni in pdf
.LookIn = PercorsoFilePDF
'' Cerca il disegno che si trova nella TextBox
.Filename = X & ".pdf"
'' Se eseguendo la ricerca trovi il file (execute sarà 1, quindi 'maggiore di zero), aprire il disegno e chiudere UserForm
If .Execute() > 0 Then
NomeFile = PercorsoFilePDF & X & ".pdf"
Call ExecutiveFile(NomeFile)
Unload Me
Else
'' Altrimenti avvisi con questo messaggio:
MsgBox "Disegno non trovato."
End If
End With
'' Set fs = Nothing
End Sub
'' # SubRoutine per apertura programma PDF predefinito
Public Sub ExecutiveFile(FilePath As String)
On Error GoTo error
Dim ret As Integer
ret = Shell("rundll32.exe url.dll, FileProtocolHandler " & (FilePath))
Exit Sub
error:
MsgBox Err.Description, vbExclamation, "Errore"
End Sub |