Kamis, 04 April 2019

Re: [MS_AccessPros] Does an URL Exist (repost) Problem solved!

 

I like that!  


And useful too.

Thank you,

Patty

On Apr 4, 2019, at 11:11 AM, Peter Randløv randlov@post9.tele.dk [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Dear friends
By googling the error code I eventually solved the problem:
The string imageURL has to include http://  - and it works!
We have a saying, which translated from Danis is something like: "A blind hen can also find a grain"
Best regards
Peter

Den 04-04-2019 kl. 13:36 skrev Peter Randløv randlov@post9.tele.dk [MS_Access_Professionals]:
 

Dear friends
In my DB with 30,000 stereoscopic images there is normally an image for each record. If not, an alternative image will be shown.
In the online version the check is:

If Dir(Image) = "" Then    'check if image exists

but obviously it is not that easy off line.
From the internet I have found some code, but I cannot make it work:
In a module I have following function:

Option Compare Database
Option Explicit
Public HttpRequest As Object
_______________________________________________________________________
Public Function URLExists(imageURL As String) As Boolean

Dim Request As Object
Dim ff As Integer
Dim rc As Variant

'On Error GoTo Endnow
Set Request = CreateObject("WinHttp..WinHttpRequest.5.1")
With Request
.Open "GET", imageURL, False 'OBJECT REQUIRED
.Send
rc = .StatusText
End With
Set Request = Nothing
If rc = "OK" Then URLExists = True
Exit Function
Endnow:
End Function

For the form, which opens the URL (the image), the code is:

Private Sub Form_Current()
   Dim imageURL As String
   Dim Filename As String
   Filename = [LBNR] & ".jpg"
imageURL = "www.fotohistoricum.dk/rods/samling/" & Left([LBNR], 2) & "/" & Filename
URLExists (imageURL)
MsgBox imageURL, vbInformation, URLExists(imageURL) 'gives the correct URL and "False"
'some code missing here
   With Me.Webbrowser20
      .ControlSource = "=" & """" & imageURL & """"
    End With
End Sub

The function URLExists always return "false", also if the image exists.
The problem is in the line in bold with the error message "Object required".
Any suggestion on what I am doing wrong?

Best regards
Peter




__._,_.___

Posted by: Patricia Mapes <patty.mapes@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar