Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to navigate to a website using VBA. The problem is that I get an
IE message box that pops up before I can actually reach the page. In order to reach the page, I need to "click OK" or press enter, but I do not know how to do this using VBA. I have tried the sendkeys method, but I was unsuccessful. The code accesses a password protected site so I cannot show it, but it is very basic: Sub Get_Info Set IE = CreateObject("InternetExplorer.Application") IE.Navigate "Website address here" "Click Ok/Press Enter when message box appears <---- Here is the problem" ... gather information from the website End Sub Any help would be greatly appreciated. Thanks. Dan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to "click OK" or press enter, but I do not know how
to do this using VBA. You need something like: Set oForm = oIE.Document.forms(0) oForm("OK").Click ....where "OK" is the name of the item to click. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I gave it a shot, but I am still having trouble. The message box is actually
being displayed when I click (using VBA) on a radio button on the website. Once the box is up, I cannot get VBA to move to the next line of code until the box is dismissed. Is there any way to disable alerts in IE (like application.displayalerts = false in VBA)? Dan "Randy Harmelink" wrote: I need to "click OK" or press enter, but I do not know how to do this using VBA. You need something like: Set oForm = oIE.Document.forms(0) oForm("OK").Click ....where "OK" is the name of the item to click. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dan Hatola wrote: I gave it a shot, but I am still having trouble. The message box is actually being displayed when I click (using VBA) on a radio button on the website. Once the box is up, I cannot get VBA to move to the next line of code until the box is dismissed. Is there any way to disable alerts in IE (like application.displayalerts = false in VBA)? Dan "Randy Harmelink" wrote: I need to "click OK" or press enter, but I do not know how to do this using VBA. You need something like: Set oForm = oIE.Document.forms(0) oForm("OK").Click ....where "OK" is the name of the item to click. Hi .... Have you tried ActiveWorkbook.FollowHyperlink ..... I think useing this method doesnt invoke the alert to open a webpage .... Cheers , |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Put the following in a standard module:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Public Enum eWindowState wsNormal = 1 wsMin = 2 wsMax = 3 End Enum Public Function OpenLocation(URL As String, WindowState As eWindowState) As Long Dim hwnd As Long Dim retHwnd As Long retHwnd = ShellExecute(hwnd, "open", URL, vbNullString, vbNullString, WindowState) OpenLocation = retHwnd End Function HTH, Nick Hebb http://www.breezetree.com |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for all of the feedback. Unfortunately I am still stuck. I think the
issue has to do with my inability to trap events in IE while I am running VBA macros from Excel. As soon as the message box appears from IE, I cannot move to the next line of VBA code. I have heard that it is possible to create an instance of IE "With Events" but that it can come with the expense of a lot of "overhead." Does anyone have any experience with this? Dan "Nick Hebb" wrote: Put the following in a standard module: Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Public Enum eWindowState wsNormal = 1 wsMin = 2 wsMax = 3 End Enum Public Function OpenLocation(URL As String, WindowState As eWindowState) As Long Dim hwnd As Long Dim retHwnd As Long retHwnd = ShellExecute(hwnd, "open", URL, vbNullString, vbNullString, WindowState) OpenLocation = retHwnd End Function HTH, Nick Hebb http://www.breezetree.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening a password-protected spreadsheet from a website link | Excel Discussion (Misc queries) | |||
Update info from website to worksheet automatically, w/o opening s | Excel Discussion (Misc queries) | |||
Our new website | New Users to Excel | |||
Our new website | Excel Discussion (Misc queries) | |||
Our new website | Links and Linking in Excel |