Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1604to1608
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Leerzeichen in Hyperlink-Pfad

Leerzeichen in Hyperlink-Pfad
08.02.2018 10:29:11
Thomas
Hallo zusammen,
ich stehe mal wieder vor einem Problem.
Mit dem folgenden Code korrigiere ich Hyperlinks. Funktioniert auch tadellos.
Das doppelte "Archiv" wird aus dem Pfad entfernt.
Option Explicit
Sub hyperlink_setzen()
Dim xAnzLinks As Long, x1 As Long, Zielspalte As Long
Dim ReplaceALT As String
Dim ReplaceNEU As String
Dim tmpC1 As String, tmpC2 As String
For Zielspalte = 84 To 165  '2 = Spalte "B"
xAnzLinks = ActiveSheet.Hyperlinks.Count
ReplaceALT = "\Matrix\Region\Archiv\Archiv\"
ReplaceNEU = "\Matrix\Region\Archiv\"
For x1 = 1 To xAnzLinks
tmpC1 = ActiveSheet.Hyperlinks(x1).Address
If InStr(1, tmpC1, ReplaceALT)  0 Then                'nur ausgwählte Links ändern
'MsgBox tmpC1
If ActiveSheet.Hyperlinks(x1).Parent.Column = Zielspalte Then
tmpC1 = Replace(tmpC1, ReplaceALT, ReplaceNEU)
'MsgBox tmpC1
' HYPERLINK korrigieren
ActiveSheet.Hyperlinks(x1).Address = tmpC1
tmpC2 = "zeile " & ActiveSheet.Hyperlinks(x1).Parent.Row
tmpC2 = tmpC2 & "Spalte " & ActiveSheet.Hyperlinks(x1).Parent.Column
tmpC2 = tmpC2 & " am " & Date & " um " & Time
ActiveSheet.Hyperlinks(x1).ScreenTip = tmpC2
End If
End If
Next x1
Zielspalte = Zielspalte + 1
Next Zielspalte
End Sub
Jetzt habe ich den Code abgeändert:
Option Explicit
Sub hyperlink_setzen()
Dim xAnzLinks As Long, x1 As Long, Zielspalte As Long
Dim ReplaceALT As String
Dim ReplaceNEU As String
Dim tmpC1 As String, tmpC2 As String
For Zielspalte = 84 To 165  '2 = Spalte "B"
xAnzLinks = ActiveSheet.Hyperlinks.Count
ReplaceALT = "\Matrix\Region West\Archiv\"
ReplaceNEU = "\Matrix\Region West\Dokumente\Archiv\"
For x1 = 1 To xAnzLinks
tmpC1 = ActiveSheet.Hyperlinks(x1).Address
If InStr(1, tmpC1, ReplaceALT)  0 Then                'nur ausgwählte Links ändern
'MsgBox tmpC1
If ActiveSheet.Hyperlinks(x1).Parent.Column = Zielspalte Then
tmpC1 = Replace(tmpC1, ReplaceALT, ReplaceNEU)
'MsgBox tmpC1
' HYPERLINK korrigieren
ActiveSheet.Hyperlinks(x1).Address = tmpC1
tmpC2 = "zeile " & ActiveSheet.Hyperlinks(x1).Parent.Row
tmpC2 = tmpC2 & "Spalte " & ActiveSheet.Hyperlinks(x1).Parent.Column
tmpC2 = tmpC2 & " am " & Date & " um " & Time
ActiveSheet.Hyperlinks(x1).ScreenTip = tmpC2
End If
End If
Next x1
Zielspalte = Zielspalte + 1
Next Zielspalte
End Sub
Leider funktioniert es so nicht. Ich vermute es liegt an den Leerzeichen im Dateipfad.
Hat jemand einen Lösungsvorschlag?
Viele Grüße und besten Dank,
Thomas

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Leerzeichen in Hyperlink-Pfad
10.02.2018 09:52:02
Sepp
Hallo Thomas,
probier mal die Links in '' zu setzen.
ActiveSheet.Hyperlinks(x1).Address = "'" & tmpC1 & "'"
Gruß Sepp

AW: Leerzeichen in Hyperlink-Pfad
14.02.2018 07:54:46
Thomas
Hallo Sepp,
danke für die Antwort. Hat funktioniert!
Gruß,
Thomas
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige