June 2006 Entries

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.

When the games are playing, go to Start/Run and enter

telnet ascii-wm.net 2006

This will give you a telnet session to the live commentary.

This came with e-mail from my friend Selcuk...

Search



About me

Hi, my name is Gurkan Yeniceri. I am a software engineer with 8 years of experience in both public and private sectors. I have been generally writing about software engineering and Microsoft technologies since March 2005 on this site.
View Gurkan Yeniceri's profile on LinkedIn

Contact

If you would like to contact with me you can use the contact page here. I will try to respond it in a timely manner (I will try my best). You can also contact with me via Microsoft Live Messenger with the address gyeniceri {AT} hotmail {DOT} com.
If you are one of my Turkish readers, you may want to visit my Turkish blog here.

If you would like to read my site with an RSS reader like RSS Bandit, you may want to use to subscribe.

RSS 2.0

Advertisement


Bookmark this site

del.icio.us digg NewsVine YahooMyWeb Reddit Spurl TailRank BlinkList Furl Shadows blogmarks
    www.flickr.com
    This is a Flickr badge showing public photos from gurkanyeniceri. Make your own badge here.
    There are 133 posts and 88 comments on this site. Other sites also linked it 7 times.

    Advertisement