Macro to jump to a particular location on the Internet through the use of a Word macro that uses an input box:   Return to List

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
    lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Sub Main()
On Error GoTo FINAL_BYE

' Setting up the default -- for the input box
If Len(Selection.Text) > 0 Then
    MyURLAddress = Selection.Text
Else
    MyURLAddress = "www.yahoo.com"
End If

' Obtaining input from the User (or taking the default)
Input_URL = InputBox("Enter the URL for your default browser", _
            "             Jump to the Internet", MyURLAddress, 3000, 2500)
If StrPtr(Input_URL) = 0 or Len(Input_URL) = 0 Then GoTo Exit Sub
Input_URL = TrimSelection(Input_URL)
ShellExecute 0&, vbNullString, Input_URL, vbNullString, _
     vbNullString, SW_SHOWNORMAL
FINAL_BYE:
End Sub

' Routine trim function
Private Function TrimSelection(Temp)
TRIM_LOOP:
If Left(Temp, 1) = Chr(32) Or Left(Temp, 1) = Chr(9) Or Left(Temp, 1) = "." Then
    Temp = Right(Temp, Len(Temp) - 1)
    GoTo TRIM_LOOP
ElseIf Right(Temp, 1) = Chr(32) Or Right(Temp, 1) = Chr(9) Or Right(Temp, 1) = Chr(13) Or _
    Right(Temp, 1) = Chr(10) Then
    Temp = Left(Temp, Len(Temp) - 1)
    GoTo TRIM_LOOP
End If
TrimSelection = Temp
End Function



Note to Webmaster