Code von Ehrensberger/K.Rola
13.04.2007 13:23:55
Ceci
Hallo Forum,
ich möchte testen ob eine Internetseite (Hyperlink) existiert oder nicht und zwar ohne die Seite wirklich zu öffnen.
In der Recherche habe ich den Code von Josef Ehrensberger bzw. K.Rola gefunden, der laut Fragesteller super funktioniert. Nur bei mir eben nicht. Laut dem Code, existiert die Internetseite nicht, obwohl es sie definitiv gibt. Was mache ich falsch?
hier der Code, mfg Ceci
VON SEPP:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Declare
Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" ( _
ByVal lpszUrl As String, _
ByVal dwFlags As Long, _
ByVal dwReserved As Long) As Long
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Function URLExist(chkUrl As String) As Boolean
URLExist = InternetCheckConnection(chkUrl, FLAG_ICC_FORCE_CONNECTION, 0&) <> 0
End Function
Sub testURL()
Dim rng As Range
Dim strURL As String
For Each rng In Range("A1:A20")
strURL = rng.Text
If Not strURL Like "http://*"
Then strURL = "http:
_
& strURL
rng.Offset(0, 1) = IIf(URLExist(strURL), "existiert", "existiert nicht")
Next
End Sub
VON K.ROLA:
Option Explicit
Private Const FIFC = &H1
Private Declare
Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal _
lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Sub Hyperlink_testen()
Dim objHL As Hyperlink
For Each objHL In ActiveSheet.Hyperlinks
If InternetCheckConnection(objHL.Address, FIFC, 0&) = 0 Then
MsgBox "Fehlerhafte URL in " & objHL.Range.Address(0, 0) & Space(10), 64, "Weise hin..."
objHL.Range.Select
Else
MsgBox "Link ok in Zelle " & objHL.Range.Address(0, 0) & Space(10), 64, "Gebe bekannt..."
End If
Next
End Sub