Devo creare un ON ERROR GOTO affinchè al verificarsi del'errore "percorso non corretto" nella stringa
c:\progra~1\micros~2\office11\winword.exe
mi vada al percorso:
c:\progra~1\micros~1\office11\winword.exe
in una Sub ho fatto così:
sub originaria:
Sub modificata:codice:Sub Documento_Click () Dim NomeFile As String, Tipo As String, x As Integer NomeFile = LeggiNomeMDB() ' Visualizza la finestra di dialogo per l'apertura dei file. If NomeFile = "" Then Exit Sub Else NomeFile = LTrim(RTrim(NomeFile)) Tipo = Right(NomeFile, 3) Debug.Print Tipo If Tipo = "DOC" Then If 1 <> 0 Then x = Shell("c:\progra~1\micros~2\office11\winword.exe" & NomeFile, 3) Else x = Shell("c:\winword\winword.exe " & NomeFile, 3) End If Else If 1 <> 0 Then x = Shell("c:\progra~1\micros~2\office11\excel.exe " & NomeFile, 3) Else x = Shell("c:\excel\excel.exe " & NomeFile, 3) End If End If End If End Sub
codice:Sub Richiama (Parametro As String, Secondo As Long, Flag As Integer) On Error GoTo RichiamaMaledettaTilde :-) Dim Path As String, file As String, x As Integer, Tipo As Integer Dim filefine As String Path = DLookup("[Path]", "Procedure", "[Procedura]='" + Parametro + "'") file = DLookup("[File]", "Procedure", "[Procedura]='" + Parametro + "'") Tipo = DLookup("[Tipo File]", "Procedure", "[Procedura]='" + Parametro + "'") If Flag = 1 Then Path = Path & Mid(Str(Secondo), 2) & "\" End If filefine = Path & file If Tipo = 1 Then If Len(Dir$("z:\luca\win.txt")) <> 0 Then x = Shell("c:\progra~1\micros~2\office11\winword.exe " & filefine, 3) Else x = Shell("c:\winword\winword.exe " & filefine, 3) End If Else If Len(Dir$("z:\luca\win.txt")) <> 0 Then x = Shell("c:\progra~1\micros~2\office11\excel.exe " & filefine, 3) Else x = Shell("c:\excel\excel.exe " & filefine, 3) End If End If Exit Sub RichiamaMaledettaTilde :-) : If Tipo = 1 Then If Len(Dir$("z:\luca\win.txt")) <> 0 Then x = Shell("c:\progra~1\micros~1\office11\winword.exe " & filefine, 3) Else x = Shell("c:\winword\winword.exe " & filefine, 3) End If Else If Len(Dir$("z:\luca\win.txt")) <> 0 Then x = Shell("c:\progra~1\micros~1\office11\excel.exe " & filefine, 3) Else x = Shell("c:\excel\excel.exe " & filefine, 3) End If End If Resume Next End Sub
ora però non riesco ad inserire un ERROR GOTO in quest'altra Sub:
codice:Sub Documento_Click () Dim NomeFile As String, Tipo As String, x As Integer NomeFile = LeggiNomeMDB() ' Visualizza la finestra di dialogo per l'apertura dei file. If NomeFile = "" Then Exit Sub Else NomeFile = LTrim(RTrim(NomeFile)) Tipo = Right(NomeFile, 3) Debug.Print Tipo If Tipo = "DOC" Then If 1 <> 0 Then x = Shell("c:\progra~1\micros~1\office11\winword.exe " & NomeFile, 3) Else x = Shell("c:\winword\winword.exe " & NomeFile, 3) End If Else If 1 <> 0 Then x = Shell("c:\progra~1\micros~1\office11\excel.exe " & NomeFile, 3) Else x = Shell("c:\excel\excel.exe " & NomeFile, 3) End If End If End If End Sub

Rispondi quotando