Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate Hyperlink field w/o opening actual document 2

Status
Not open for further replies.

ump38

Programmer
Jul 17, 2001
29
0
0
US
I have an Access 2003 database that allows a user to click an icon to open a Word document (if one exists) that defines the process associated with a displayed control. This Word narrative is maintained in a separate and independent enterprise repository that provides for archiving, versioning control, and user update permission restriction. The "current" version of this document can be accessed easily enough using standard HTTP protocol.

The hyperlink address is maintained as 2 separate data elements for each control in a table, and with very little manipulation a valid URL can be generated that points to the document. When initially setting this up, I had to manually determine the full correspondingURL path and document name. Works like a champ!

My issue is that I don't necessarily know if or when the owners of these narratives change the location in the repository system that effectively makes my table entries generate an invalid URL that no longer points to the proper location. I've written a short piece of code that loops through all the constructed URLS and helps to validate that the document still exists where it was expected to be... the main line being: Application.FollowHyperlink ThisURL, , True, False

This works fine in helping detect URLS that are no longer valid, but I really don't want to physically have to open 250+ documents only to ultimately close these. I am trying to determine if there is a means to validate (or invalidate) the URL with code without having to physically open (and subsequently close) the associated Word document.

Is there any Access functionality to do this? or am I likely stuck with the 10-12 minutes exercise that I've created and know it works... when I just ran it I see that 30 of 254 URLs that were once legit are no longer, meaning I need to research and possibly reset those 30 as appropriate. I know that the follow-up will always be a manual process that could take a while...just looking to speed up that 1st part of this maintenance task.

Thanks for any advise you can offer up.
 
Have you considered Dir?

If the URL is, say, "Z:\Data\" & "Doc1.doc"

Dir (strURL)

Will return an empty string ("").
 
Unfortunately, these are all HTTP addresses (EX: Oxley\SOX 2007\Enterprise-Wide Controls\Financial Controls\PSO\PSServices\Process Documentation\PD_APT002_PSO_PSServices_CrteSvcPO_nar).

DIR doesn't handle these. Thanks though.
 
This example is adapted from classic ASP. You will need to ensure that the URL starts with " Be careful of False results, you may need to check further.

Code:
Function IsLink(url)
Dim http As Object
Dim xmlhttp As Object
 
    Set http = CreateObject("MSXML2.ServerXMLHTTP.4.0")
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
 
    On Error Resume Next
 
    xmlhttp.Open "GET", url, False
    'This alternative can return status 405 in some cases
    'xmlhttp.Open "HEAD", url, False
    xmlhttp.Send ""
 
    'You can get the status of the page, if you wish
    'Status = xmlhttp.Status
 
    If Err.Number <> 0 Or Status <> 200 Then
        IsLink = False
    Else
        IsLink = True
    End If
 
    Set xmlhttp = Nothing
 
End Function
 
Thanks. I'll take your code snippet for a spin after lunch and tweak as needed and see if this produces the desired results in validating a URL address.
 
Remou -
Finally had a chance to try this...works perfectly and accomplishes exactly what I need. Can now cycle through 250+ HTTP addresses and get validation within 60 seconds without any intervention. Wonderful!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top