XFN Link Creator

I was looking for a simple and easy way of inserting XFN relations into links. I
usually use MS FrontPage for my blog writings. So I mocked up this XFN Link
creator VBA macro. Here is how I did it.

Create a macro called CreateXFNLink and insert the code below (copy paste it
into Notepad first to get rid of the HTML mark-up).

Public Sub
CreateXFNLink()
    Dim objRange
As IHTMLTxtRange
    Set objRange = ActiveDocument.Selection.createRange

    If Len(objRange.Duplicate.Text)
> 0 Then
        Load
UserForm1
        UserForm1.Show
    Else
        MsgBox
“You must select a piece of text first”,
vbExclamation
, “Warning”
    End If
End Sub

Now create a form like the one below called UserForm1. Put necessary
checkboxes, a button and a text box to enter the link on the form.

And here is the code for the Create button:

Private Sub
CommandButton1_Click()
    ‘<a href=”http://blog.example.com/”
rel=”friend met”>A Friend</a>

    Dim link
As String
    Dim objRange
As IHTMLTxtRange
    Set objRange =
ActiveDocument.Selection.createRange

    link = “<a href=”””
    link = link & TextBox1.Text & “””” & ” rel=”””

    If CheckBox1
Then
        link = link & CheckBox1.Caption & ” “
    End If
    If CheckBox2
Then
        link = link & CheckBox2.Caption & ” “
    End If
    If CheckBox3
Then
        link = link & CheckBox3.Caption & ” “
    End If
    If CheckBox4
Then
        link = link & CheckBox4.Caption & ” “
    End If
    If CheckBox5
Then
        link = link & CheckBox5.Caption & ” “
    End If
    If CheckBox6
Then
        link = link & CheckBox6.Caption & ” “
    End If
    If CheckBox7
Then
        link = link & CheckBox7.Caption & ” “
    End If
    If CheckBox8
Then
        link = link & CheckBox8.Caption & ” “
    End If
    If CheckBox9
Then
        link = link & CheckBox9.Caption & ” “
    End If
    If CheckBox10
Then
        link = link & CheckBox10.Caption & ”

    End If
    If CheckBox11
Then
        link = link & CheckBox11.Caption & ”

    End If
    If CheckBox12
Then
        link = link & CheckBox12.Caption & ”

    End If
    If CheckBox13
Then
        link = link & CheckBox13.Caption & ”

    End If
    If CheckBox14
Then
        link = link & CheckBox14.Caption & ”

    End If
    If CheckBox15
Then
        link = link & CheckBox15.Caption & ”

    End If
    If CheckBox16
Then
        link = link & CheckBox16.Caption & ”

    End If
    If CheckBox17
Then
        link = link & CheckBox17.Caption & ”

    End If
    If CheckBox18
Then
        link = link & CheckBox18.Caption & ”

    End If

    link = Mid$(link, 1,
Len(link) – 1)

    link = link & “””>” & objRange.Duplicate.Text & “</a>”

    objRange.pasteHTML link

    Unload Me
End Sub

When you select a text in the FrontPage run the macro CreateXFNLink and
select the relations that you want to implement and enter the hyperlink that you
want to link and hit the Create button. Your link will be created with all the
XFN relations that you have selected.

Happy blogging.

Posted in Bilişim, English.