Create Hyperlink from Selected Text

W

William Main

I find that I end up pasting a lot of URLs in to a page as
i am designing it. I then need to select it and convert it
to a link with the insert hyperlink command.

I wrote a simple VBA script to handle this so that all I
have to do is select the url (usually the whole line) then
click a menu item I created which envokes my code.

My code follows:

Option Explicit

Sub CreateLink()
Dim oSelected As IHTMLSelectionObject
Dim oTextRange As IHTMLTxtRange
Dim strLink As String

Set oSelected =
FrontPage.Application.ActiveDocument.Selection
Set oTextRange = oSelected.createRange
strLink = oTextRange.Text
oTextRange.execCommand "CreateLink", False, strLink
End Sub

I also added a menu item under the Help menu to bring up
the Frontpage SDK help file. It follows:

Public Sub FPSDK()
Call Shell("C:\WINDOWS\hh.exe d:\FPSDK\FPSDK.chm",
vbNormalFocus)
End Sub

Both of these should me in a module. Then you can add the
macros to menu items by right clicking on the Menu in FP
and selecting Customize.
 
M

MD WebsUnlimited.com

Hi William,

I'm wondering why you would want to do this?

1. Select the text
2. Right click
3. Click on Hyperlink Properties
 
W

William Main

I will copy and paste text into the current page. I end up
with text urls. If I select them and right click then
select Hyperlink Properties the address is blank.

So now i just select the text containing the URL then
click my menu item and voila, instant hyperlink
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top