+ Reply to Thread
Results 1 to 4 of 4

URL cannot open Cannot download the information you requested issue

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    URL cannot open Cannot download the information you requested issue

    hi,

    I have an excel sheet with thousands of lines. there is a column called URL where i have again thousands of url lines. As the URL links to some contents that might expire (the URL is not working), therefore it's reasonable that i got an error message as the post's title:"URL cannot open Cannot download the information you requested".

    My question is, since there are thousands lines, is there a way i can run a query and automatically highlight those url cells that can't open? in that case, it will save me hours instead of just right click every cell.

    super thanks!!!

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: URL cannot open Cannot download the information you requested issue

    Hi gladiator,

    I may have a solution for your problem in the attached file, which uses Internet Explorer Automation to check the validity of your hyperlinks. The code was tested on a Vista 32 bit system, Using Excel 2003, and Internet Explorer 8, with Verizon Fios Internet (Northern NJ). On my system it took one to two seconds to test each URL.

    There are 4 types of Hyperlinks in Excel that I know of:
    a. URLs
    b. mailto
    c. Link to an external file
    d. Link to a cell inside the Excel sheet

    The code only checks URLs, but identifies the other types of hyperlinks.

    The following items in the VBA code can be modified to customize the file to a specific spreadsheet without having any programming skills:
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'The following 6 lines can be changed to Specific Worksheet Requirements
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Const sSourceWorksheetNAME = "Sheet1"
    Public Const sHyperlinkDataCOLUMN = "D"
    Public Const nStartRowDATUM = 6                           'One row BEFORE The start row
    Public Const sDomainNameNotFoundDisplayCELL = "D25"
    Public Const sUrlNotFoundDisplayCELL = "D26"
    Public Const sUrlIsAFileDisplayCELL = "D27"

    The following items in the VBA code can be modifed if the error messages for SPECIFIC SITUATIONS returned by your Internet Provider differ from the messages I received. There are command buttons in the Worksheet to test for each of the three error situations.
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'The following 3 lines can be changed to be consistent with Error Messages
    'returned by your Internet Service Provider and Your Specific Browser
    'Original messages were derived from: Vista 32 Bit, Internet Explorer 8, Verizon ISP (Northern New Jersey)
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Const sBadDOmainNameSUBSTRING = "search.dnsassist.verizon.net"
    Public Const sUrlNotFoundSUBSTRING = "http_404"
    Public Const sUrlIsAFileSUBSTRING = "ieframe.dll/dnserror.htm"
    Lewis

    Complete code follows (64 bit CONDITIONAL COMPILATION not tested):
    Option Explicit
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'The following 6 lines can be changed to Specific Worksheet Requirements
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Const sSourceWorksheetNAME = "Sheet1"
    Public Const sHyperlinkDataCOLUMN = "D"
    Public Const nStartRowDATUM = 6
    Public Const sDomainNameNotFoundDisplayCELL = "D25"
    Public Const sUrlNotFoundDisplayCELL = "D26"
    Public Const sUrlIsAFileDisplayCELL = "D27"
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'The following 3 lines can be changed to be consistent with Error Messages
    'returned by your Internet Service Provider and Your Specific Browser
    'Original messages were derived from: Vista 32 Bit, Internet Explorer 8, Verizon ISP (Northern New Jersey)
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Const sBadDOmainNameSUBSTRING = "search.dnsassist.verizon.net"
    Public Const sUrlNotFoundSUBSTRING = "http_404"
    Public Const sUrlIsAFileSUBSTRING = "ieframe.dll/dnserror.htm"
    
    #If VBA7 And Win64 Then
      ' 64 bit Excel
      'NOTE: The following line is supposed to be RED in 32 bit Excel
      Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongLong)
    #Else
      ' 32 bit Excel
      Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #End If
    
    
    #If VBA7 And Win64 Then
      ' 64 bit Excel
      'NOTE: The following line is supposed to be RED in 32 bit Excel
      Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
    #Else
      ' 32 bit Excel
      Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    #End If
    
    Private Const SW_MAXIMIZE = 3
    Private Const SW_SHOWNORMAL = 1
    Private Const SW_SHOWMINIMIZED = 2
    
    
      
    Sub ClearColorsOHyperlinkCells()
      'This clears color from all 'contiguous cell with hyperlinks' in a specific column
      
      Dim ws As Worksheet
      
      Dim iRow As Long
      
      Dim bNeedMore As Boolean
      
      Dim sValue As String
    
      'Create the Worksheet object
      Set ws = Sheets(sSourceWorksheetNAME)
      
      iRow = nStartRowDATUM    'one row before the start row
    
      bNeedMore = True
      While bNeedMore
        
        'Increment the input row number
        iRow = iRow + 1
        
        'Get the value in the cell
        sValue = Trim(ws.Cells(iRow, sHyperlinkDataCOLUMN).Text)
      
        If Len(sValue) = 0 Then
        
          'Exit if there is no data in the cell
          bNeedMore = False
          
        Else
          'Clear color from the cell
          ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.ColorIndex = xlNone
        End If
          
      Wend
    
      'Clear the worksheet objet
      Set ws = Nothing
      
    End Sub
    
    Sub CheckHyperlinkValidity()
      'This checks the validity of Hyperlinks located in a specific column
    
      Dim ie As Object
      Dim ws As Worksheet
      
      Dim iRow As Long
      Dim myRGB_Cyan As Long
      Dim myRGB_Green As Long
      Dim myRGB_Magenta As Long
      Dim myRGB_Red As Long
      Dim myRGB_Yellow As Long
      
      Dim bNeedMore As Boolean
      
      Dim sDocumentUrl As String
      Dim sUrl As String
      Dim sUrlActive As String
      Dim sUrlStatusBarText As String
      Dim sUrlLocationName As String
      Dim sValue As String
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Initialization
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      
      myRGB_Cyan = RGB(0, 255, 255)            'No Hyperlink
      myRGB_Green = RGB(0, 255, 0)             'Valid URL Hyperlink
      myRGB_Magenta = RGB(255, 0, 255)         'Valid Domain Name - URL cannot be found
      myRGB_Red = RGB(255, 0, 0)               'Bad Domain Name
      myRGB_Yellow = RGB(255, 255, 0)          'Hyperlink, but NOT URL
      
      'Verify that the Source Data Sheet Exists
      If LjmSheetExists(sSourceWorksheetNAME) = False Then
        MsgBox "TERMINATING.  Source Worksheet DOES NOT EXIST." & vbCrLf & _
               "Sheet Name: '" & sSourceWorksheetNAME & "'"
        Exit Sub
      End If
      
      'Clear the colors (if any) from the Hyperlink Cells
      Call ClearColorsOHyperlinkCells
      
      'Create the Worksheet object
      Set ws = Sheets(sSourceWorksheetNAME)
        
      'Enable the 'ESC' Key Error Handler
      'This also means any RUNTIME ERROR will jump to the Error Handler
      On Error GoTo ERROR_HANDLER
      Application.EnableCancelKey = xlErrorHandler
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Create the Internet Explorer Object
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Set ie = CreateObject("InternetExplorer.Application")
      ie.Visible = True
      ShowWindow ie.hwnd, SW_SHOWMINIMIZED
      On Error GoTo ERROR_HANDLER
        
      Debug.Print "Starting at " & Now()
    
      iRow = nStartRowDATUM    'one row before the start row
      
      bNeedMore = True
      While bNeedMore
        
        'Increment the input row number
        iRow = iRow + 1
        
        'Get the value in the cell
        sValue = Trim(ws.Cells(iRow, sHyperlinkDataCOLUMN).Text)
      
        If Len(sValue) = 0 Then
        
          'Exit if there is no data in the cell
          bNeedMore = False
          
        ElseIf ws.Cells(iRow, sHyperlinkDataCOLUMN).Hyperlinks.Count > 0 Then
          sUrl = Cells(iRow, sHyperlinkDataCOLUMN).Hyperlinks(1).Address
          'Debug.Print Format(iRow, "00000  ") & "Address=" & sUrl
          'Debug.Print Format(iRow, "00000  ") & "Sub_adr=" & Cells(iRow, sHyperlinkDataCOLUMN).Hyperlinks(1).SubAddress
          
          
          
          If InStr(sUrl, "mailto") > 0 Then
            Debug.Print Format(iRow, "00000  ") & "  No URL Hyperlink - E-Mail Hyperlink"
            ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Yellow
            
          ElseIf Len(sUrl) > 0 Then
            
            'Navigate to the URL
            ie.Navigate sUrl
      
            'Wait until Internet Explorer is not busy and ready
            Do While ie.Busy Or ie.readyState <> 4
              Sleep 200
            Loop
      
            'After not busy and ready, wait until status is 'Done'
            If ie.StatusText <> "Done" Then
              Sleep 200
            End If
    
            sUrlActive = ie.LocationURL
            sUrlStatusBarText = ie.StatusText
            sUrlLocationName = ie.LocationName
            sDocumentUrl = ie.Document.URL
            'Debug.Print "''''''''''''''''''''''"
            'Debug.Print sUrlActive
            'Debug.Print sUrlStatusBarText
            'Debug.Print sUrlLocationName
            'Debug.Print sDocumentUrl
    
            'Color the cell  based on the Document URL returned
            If InStr(sDocumentUrl, sBadDOmainNameSUBSTRING) > 0 Then
              Debug.Print Format(iRow, "00000  ") & "  Bad Domain Name"
              ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Red       'Bad Domain Name
            ElseIf InStr(sDocumentUrl, sUrlNotFoundSUBSTRING) > 0 Then
              Debug.Print Format(iRow, "00000  ") & "  Valid Domain Name - URL cannot be found"
              ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Magenta   'Valid Domain Name - URL cannot be found
            ElseIf InStr(sDocumentUrl, sUrlIsAFileSUBSTRING) > 0 Then
              Debug.Print Format(iRow, "00000  ") & "  NO URL Hyperlink - URL is a file name"
              ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Yellow    'No URL Hyperlink - URL is a file name
            Else
              Debug.Print Format(iRow, "00000  ") & "  Success"
              ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Green     'Success
            End If
            
          Else
            Debug.Print Format(iRow, "00000  ") & "  No URL Hyperlink - Link to this file"
            ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Yellow
          End If
        Else
          Debug.Print Format(iRow, "00000  ") & "  No URL Hyperlink"
          ws.Cells(iRow, sHyperlinkDataCOLUMN).Interior.Color = myRGB_Cyan
        End If
        
        'Scroll down so the user can see progress
        ActiveWindow.SmallScroll Down:=1
      Wend
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Exit and Error Handler
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ERROR_HANDLER:
      If Err.Number = 18 Then
        MsgBox "Program Terminated because User Pressed the 'ESC' Key."
      End If
        
      ie.Quit
      Set ie = Nothing
      Set ws = Nothing
      Debug.Print "Ended at " & Now()
        
    End Sub
    
    Sub GenerateBadDomainNameError()
      'This uses Internet Explorer to attempt to access a URL with a 'Bad Domain Name'
    
      Const sUrl = "http://www.XXXexcelforum.com/whocares.html"
      Call GenerateInternetExplorerErrorGeneric(sUrl, sDomainNameNotFoundDisplayCELL)
        
    End Sub
    
    Sub GenerateURLNotFoundError()
      'This uses Internet Explorer to attempt to access a URL with a 'Good Domain Name' and an Invalid URL
    
      Const sUrl = "http://www.excelforum.com/junque.html"
      Call GenerateInternetExplorerErrorGeneric(sUrl, sUrlNotFoundDisplayCELL)
        
    End Sub
    
    Sub GenerateURLIsAFileError()
      'This uses Internet Explorer to attempt to access a URL that is not a URL, but is actually a file name
      Const sUrl = "x.txt"
      Call GenerateInternetExplorerErrorGeneric(sUrl, sUrlIsAFileDisplayCELL)
    
    End Sub
    
    Sub GenerateInternetExplorerErrorGeneric(sUrlToTest As String, sCell As String)
      'This TESTS a URL using Internet Explorer and puts the value of 'document.URL' in the input cell
      
      Dim ie As Object
      Dim iRow As Long
      
      Dim bNeedMore As Boolean
      
      Dim sDocumentUrl As String
      Dim sUrlActive As String
      Dim sUrlStatusBarText As String
      Dim sUrlLocationName As String
      Dim sValue As String
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Initialization
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        
      'Verify that the Source Data Sheet Exists
      If LjmSheetExists(sSourceWorksheetNAME) = False Then
        MsgBox "TERMINATING.  Source Worksheet DOES NOT EXIST." & vbCrLf & _
               "Sheet Name: '" & sSourceWorksheetNAME & "'"
        Exit Sub
      End If
      
      Sheets(sSourceWorksheetNAME).Range(sCell) = ""
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Create the Internet Explorer Object
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Set ie = CreateObject("InternetExplorer.Application")
      ie.Visible = True
      ShowWindow ie.hwnd, SW_SHOWMINIMIZED
      On Error GoTo Handler
        
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Attempt to Access the Website URL
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      
      'Navigate to the URL
      ie.Navigate sUrlToTest
      
      'Wait until Internet Explorer is not busy and ready
      Do While ie.Busy Or ie.readyState <> 4
        Sleep 200
      Loop
      
      'After not busy and ready, wait until status is 'Done'
      If ie.StatusText <> "Done" Then
        Sleep 200
      End If
    
      sUrlActive = ie.LocationURL
      sUrlStatusBarText = ie.StatusText
      sUrlLocationName = ie.LocationName
      sDocumentUrl = ie.Document.URL
      'Debug.Print "''''''''''''''''''''''"
      'Debug.Print sUrlActive
      'Debug.Print sUrlStatusBarText
      'Debug.Print sUrlLocationName
      'Debug.Print sDocumentUrl
    
      Sheets(sSourceWorksheetNAME).Range(sCell) = sDocumentUrl
    
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Exit and Error Handler
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Handler:
        ie.Quit
        Set ie = Nothing
        
    End Sub
    
    Public Function LjmSheetExists(SheetName As String) As Boolean
    'Return value TRUE if sheet exists
    
      On Error Resume Next
    
      If Sheets(SheetName) Is Nothing Then
        LjmSheetExists = False
      Else
        LjmSheetExists = True
      End If
      On Error GoTo 0
      
    End Function
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: URL cannot open Cannot download the information you requested issue

    hi!

    Super thanks for your note. However I'm on a mac system, is there a way to use chrome or safari?

    Thanks

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: URL cannot open Cannot download the information you requested issue

    There apparently is a way using CreateObject("WinHttp.WinHttpRequest.5.1") equivalent for MAC, which allegedly supports other browsers. However, since I don't have access to a MAC it is beyond my capabilities.

    Sorry.

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hyperlink: Cannot Download The Information You Requested
    By Hypernova in forum Excel General
    Replies: 11
    Last Post: 05-27-2024, 03:43 AM
  2. How I view information requested from a combo box?
    By Jessica C. Jara in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2006, 05:10 PM
  3. How to download information from web using VBA ?
    By Leonardo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2006, 08:30 PM
  4. Replies: 5
    Last Post: 09-01-2005, 03:05 PM
  5. [SOLVED] Hyperlink - cannot download the information you requested
    By TheRanz in forum Excel General
    Replies: 2
    Last Post: 08-22-2005, 01:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1