Alternativ-Pfad mit On Error
20.05.2014 08:32:34
Thomas
mit folgendem Code öffne ich aus Excel heraus das E-Mailprogramm Thunderbird.
Private Sub senden_Click()
Dim strAn As String
Dim strBetr As String
Dim strBody As String
Dim strAttPfad As String
Dim strThunderPfad As String
Dim strShell As String
strThunderPfad = """C:\Programme\Mozilla Thunderbird\Thunderbird.exe"""
strAn = ComboBox1 & ";" & ComboBox2 & ";" & ComboBox3 & ";" & ComboBox4 & ";" & ComboBox5 & ";" _
& ComboBox6 & ";" & ComboBox7 & ";" & ComboBox8 & ";" & ComboBox9 & ";" & ComboBox10 & ";" & ComboBox11 & ";" & ComboBox12 ' Empfänger
strBetr = TextBox1 ' Betreff
strBody = TextBox2 ' Nachricht
strShell = strThunderPfad & _
" -compose """ & _
"to='" & strAn & "'," & _
"subject='" & strBetr & "'," & _
"body=" & strBody & _
Call Shell(strShell, vbNormalFocus)
' Alle Textboxen und Comboboxen leeren
Dim objControl As Control
For Each objControl In Controls
Select Case TypeName(objControl)
Case "TextBox"
objControl.Text = ""
Case "ComboBox"
objControl.ListIndex = -1
Case "CheckBox"
objControl.Value = False
Case "OptionButton"
objControl.Value = False
End Select
Next
Email.Hide
End Sub
Mein Problem ist, dass die Excel-Datei von mehreren Leuten benutzt wird und das E-Mailprogramm Thunderbird auf zwei unterschiedlichen Pfaden liegt. Der Code müsste also so geändert werden, dass wenn er bei der Zeile:
strThunderPfad = """C:\Programme\Mozilla Thunderbird\Thunderbird.exe"""
auf einen Fehler läuft, das E-Mailprogramm in einem Alternativpfad sucht.
Der Alternativpfad wäre:
C:\Programme\Mail\Thunderbird.exe
Für eure Hilfe bedanke ich mich im Voraus.
Schöne Grüße
Thomas