'#Language "WWB-COM" Option Explicit Sub Main() CreateReciprocalLinks End Sub Sub CreateReciprocalLinks() Dim selectedItems As Object Dim topicCount As Integer Dim i As Integer Dim t1 As Object Dim t2 As Object ' Initialize topicCount = 0 Set selectedItems = ActiveDocument.Selection ' Debugging: Show the count of selected items MsgBox "Number of selected items: " & selectedItems.Count ' Iterate through the selection and count topics For i = 1 To selectedItems.Count ' Debugging: Show the type of each selected item MsgBox "Selected item " & i & " type: " & TypeName(selectedItems.Item(i)) ' Attempt to access properties specific to topics On Error Resume Next If Not IsEmpty(selectedItems.Item(i).Text) Then topicCount = topicCount + 1 MsgBox "Topic " & topicCount & " text: " & selectedItems.Item(i).Text If topicCount = 1 Then Set t1 = selectedItems.Item(i) ElseIf topicCount = 2 Then Set t2 = selectedItems.Item(i) Exit For End If End If On Error GoTo 0 Next i ' Debugging: Show the count of selected topics MsgBox "Number of selected topics: " & topicCount ' Check if exactly two topics are selected If topicCount = 2 Then ' Create reciprocal links using notes as hyperlinks AddHyperlinkNote t1, t2 AddHyperlinkNote t2, t1 MsgBox "Reciprocal links created successfully." Else MsgBox "Please select exactly two topics." End If End Sub Sub AddHyperlinkNote(sourceTopic As Object, targetTopic As Object) Dim linkText As String linkText = "Link to: " & targetTopic.Text sourceTopic.Notes.Text = sourceTopic.Notes.Text & vbCrLf & linkText End Sub