Consulting

Results 1 to 7 of 7

Thread: Solved: URL -No Highlight Search Results.

  1. #1

    Solved: URL -No Highlight Search Results.

    When use ForumSearch then URL shows:
    URL+&higlight=Searchstring+string+string..
    How to delete this end of URL with VBA in Excel Sheet?


    [vba]Private Sub CommandButton1_Click()
    Dim SWs As SHDocVw.ShellWindows
    Dim i As Integer
    Dim Adres As String
    Set SWs = New SHDocVw.ShellWindows
    For i = SWs.Count - 1 To 0 Step -1
    Adres = CStr(SWs(i).LocationURL)
    'http://www.vbaexpress.com/forum/showthread.php?t=26180&highlight=URL+Delete+INDEX

    If Adres Like "*&highlight=" Then
    All after & ("*&highlight=")..Delete


    If Adres Like "http*" Then
    Range("b1").Hyperlinks.Add _
    Anchor:=Range("b1"), _
    Address:=Adres, _
    TextToDisplay:=Adres
    Exit For
    End If
    Next i
    Range("b1").Select
    Set SWs = Nothing
    End Sub[/vba]
    Last edited by omnibuster; 04-13-2009 at 08:45 AM.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Not sure what you need. I generally delete all the hyperlinks and then refresh the ones that I want active. e.g. http://vbaexpress.com/forum/showthread.php?p=181830

  3. #3
    Thank Kenneth.
    No. I dont need delete hyperlinks.
    I want delete all after &.. included & too.
    Red colored.

    'http://www.vbaexpress.com/forum/showthread.php?t=26180&highlight=URL+Delete+INDEX

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Do you want to add the correct URL as a hyperlink then? Or do you want to navigate that window to the URL you want?

  5. #5
    I using DRJ file.(Litle modified)
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=159

    Yes. I need correct hyperlink .
    If i find interesting Link i download in my WorkBook for future....

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Oh, gotcha. This will work. Tested in IE7, loops through all tabs and gets dynamic list...
    [vba]Private Sub CommandButton1_Click()
    'Reference needed for Microsoft Internet Controls
    Dim SWs As SHDocVw.ShellWindows
    Dim i As Long, iRow As Long, Adres As String
    Set SWs = New SHDocVw.ShellWindows
    iRow = 1 'starting row
    For i = SWs.Count - 1 To 0 Step -1
    Adres = CStr(SWs(i).LocationURL)
    If Adres Like "*&highlight=*" Then
    If Adres Like "http*" Then
    Adres = Left(Adres, InStr(1, Adres, "&highlight=") - 1)
    Cells(iRow, "B").Hyperlinks.Add Anchor:=Cells(iRow, "B"), Address:=Adres, TextToDisplay:=Adres
    iRow = iRow + 1
    End If
    End If
    Next i
    Range("b1").Select
    Set SWs = Nothing
    End Sub[/vba]
    If you want the individual thread, leave this line in...
    [vba]Adres = Left(Adres, InStr(1, Adres, "&highlight=") - 1)[/vba]
    If you want the entire URL as it stands (with the highlight portion), take it out.

    HTH

  7. #7
    Big Thank for you Zack.
    I litle modified your code.
    Same time I have many opened IE Tab-s, but only Last Tab for Excel search,
    (other Tabs for news, weather: -these not for download.)
    [vba]
    Private Sub CommandButton1_Click()
    'Reference needed for Microsoft Internet Controls
    Dim SWs As SHDocVw.ShellWindows
    Dim i As Long, Adres As String
    Set SWs = New SHDocVw.ShellWindows

    For i = SWs.Count - 1 To 0 Step -1
    Adres = CStr(SWs(i).LocationURL)
    If Adres Like "*&highlight=*" Then
    Adres = Left(Adres, InStr(1, Adres, "&highlight=") - 1)
    Range("b1").Hyperlinks.Add Anchor:=Range("b1"), Address:=Adres, TextToDisplay:=Adres
    Exit For
    Else
    If Adres Like "http*" Then
    Range("b1").Hyperlinks.Add Anchor:=Range("b1"), Address:=Adres, TextToDisplay:=Adres
    Exit For
    End If
    End If
    Next i
    Range("b1").Select
    Set SWs = Nothing
    End Sub
    [/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •