Dieses Makro wandelt betitelte Hyperlinks in einem Word-Dokument in die ::url[…]-Syntax von Lawlift um, damit Titel und URL den Import überstehen.
Lawlift bietet Ihnen die Möglichkeit, eine als Hyperlink eingefügte URL mit einem Titel über die Funktion “Titel(…)” zu formatieren. Wie das genau funktioniert, haben wir Ihnen hier gezeigt.
Wenn Sie jedoch vorab ein zu automatisierendes Word-Dokument haben, das bereits solche formatierten Links enthält, werden beim direkten Kopieren in Lawlift nur die Titel übernommen, nicht aber die URLs.
Hier kann ein Makro helfen, das alle formatierten Links im Word-Dokument in die von Lawlift lesbare Form “::url[www.beispielurl.detitle(example)\]” umwandelt. Anschließend können die formatierten Links einfach aus der Word-Datei in die Lawlift-Vorlage kopiert werden. Lawlift erkennt die Ausdrücke und fügt sie als anklickbare URLs mit dem angegebenen Titel ein, wie in unserer Hilfe gezeigt.
Unformatierte Links können auch ohne Verwendung dieses Makros einfach in die Lawlift-Vorlage kopiert werden und werden von Lawlift als solche erkannt.
Hier ist ein Beispiel für ein Makro, das die Quelldatei für den Import in Lawlift vorbereitet:
Sub Format_Hyperlinks()
Dim Link As Hyperlink
Dim HTP1, HTP2 As Integer
HTP1 = 0
HTP2 = 0
'checking document if it contain URLs
If ActiveDocument.Hyperlinks.Count > 0 Then
For Each Link In ActiveDocument.Hyperlinks '------------------------
If Link.Address <> "" Then
'links vs bookmarks
If InStr(Link.Address, "http") > 0 Then '------------
Link.Range.Select
'checking for address only links
If Link.TextToDisplay = Link.Address Then
Selection.TypeText "::url[" & Link.Address & "]"
HTP1 = HTP1 + 1
Else 'if link have a text to display
Selection.TypeText "::url[" & Link.Address & " Title(" & Link.TextToDisplay & ")]"
HTP2 = HTP2 + 1
End If
End If '------------
End If
Next Link '------------------------
'statistic message
mSg = "There are " & HTP1 & " link(s) without Title." & Chr(13) & "There are " & HTP2 & " link(s) with Title." & Chr(13) & "Total " & HTP1 + HTP2 & " link(s) formatted so far."
MsgBox mSg, vbOKOnly + vbInformation, "Statistics"
Else
'if not links were found in document
MsgBox "There are no hyperlinks in this document."
End If
End Sub
Sub Format_Hyperlinks_Updated()
'------------------------------------------------'
'--------- Dealing Hyperlinks in Body -----------'
'------------------------------------------------'
Dim Link As Hyperlink
Dim HTP1, HTP2 As Integer
HTP1 = 0
HTP2 = 0
BD = 0
FT = 0
'checking document if it contain URLs
On Error Resume Next ' Handling unknown error for this time only
If ActiveDocument.Hyperlinks.Count > 0 Then
For Each Link In ActiveDocument.Hyperlinks '------------------------
'links vs bookmarks
If InStr(Link.Address, "http") > 0 Then '------------
Link.Range.Select
'checking for address only links
If Link.TextToDisplay = Link.Address Then
Selection.TypeText "::url[" & Link.Address & "]"
HTP1 = HTP1 + 1
Else 'if link have a text to display
Selection.TypeText "::url[" & Link.Address & " Title(" & Link.TextToDisplay & ")]"
HTP2 = HTP2 + 1
End If
End If
BD = BD + 1
Next Link '------------------------
Else
'if not links were found in document
MsgBox "There are no hyperlinks in the body of document."
End If
'------------------------------------------------'
'------- Dealing Hyperlinks in Footnotes --------'
'------------------------------------------------'
Dim h As Hyperlink
With ActiveDocument
If .Footnotes.Count >= 1 Then
With .StoryRanges(wdFootnotesStory)
For Each h In .Hyperlinks
If InStr(h.Address, "http") > 0 Then
h.Range.Select
'checking for address only links
If h.TextToDisplay = h.Address Then
Selection.TypeText "::url[" & h.Address & "]"
HTP1 = HTP1 + 1
Else 'if link have a text to display
Selection.TypeText "::url[" & h.Address & " Title(" & h.TextToDisplay & ")]"
HTP2 = HTP2 + 1
End If
End If
FT = FT + 1
Next h
End With
End If
End With
'------ Statistic Message -------'
mSg = "Number of Hyperlink(s) in:" & Chr(13) & "Main Document =" & BD & Chr(13) & "Footnote =" & FT & Chr(13) & Chr(13) & "There are " & HTP1 & " link(s) without Title." & Chr(13) & "There are " & HTP2 & " link(s) with Title." & Chr(13) & Chr(13) & "Total " & HTP1 + HTP2 & " link(s) formatted so far."
MsgBox mSg, vbOKOnly + vbInformation, "Statistics"
End Sub
Hinweis: Führen Sie das Makro nur einmal aus, sonst verschachteln sich die Funktionen ineinander.
Makro ausführen: siehe So fügen Sie ein Word-Makro ein und führen es aus.