vba connect to internet with wininet.dll

bestox

Board Regular
Joined
Apr 2, 2009
Messages
82
i am using vba code and try to access the internet using the wininet.dll:

Code:
Option Explicit
Public isCancelled As Boolean
Private g_URI_changed As Boolean
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Const ERROR_INTERNET_INVALID_URL = 12005
Private Const ERROR_INTERNET_UNRECOGNIZED_SCHEME = 12006
Private Const ERROR_INTERNET_NAME_NOT_RESOLVED = 12007
Private Const ERROR_INTERNET_CANNOT_CONNECT = 12029
Private Declare Function CheckURL Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Sub test1234()
Dim y As Boolean
Dim x As Long
    y = URLExist("http://www.google.com", x)
    MsgBox x
    MsgBox y
 
End Sub
Function URLExist(ByVal chkUrl As String, ByRef p_errcode As Long) As Boolean
 
    If CheckURL(chkUrl, FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
        p_errcode = Err.LastDllError
        URLExist = False
    Else
        p_errcode = 0
        URLExist = True
    End If
End Function
Msgbox X always returns 12029 (ERROR_INTERNET_CANNOT_CONNECT).

anyone knows why this can be?

i can access internet out of excel, f.e.: using a macro, typing in a hyperlink etc.; is using wininet.dll the reason? anyone has experience about this file?

thank you for any hint!
 

Forum statistics

Threads
1,082,143
Messages
5,363,378
Members
400,732
Latest member
robcooper2001

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top