Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Help Opening Website using VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default Help Opening Website using VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Help Opening Website using VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help Opening Website using VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Help Opening Website using VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Help Opening Website using VBA

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a password-protected spreadsheet from a website link Héctor Miguel Excel Discussion (Misc queries) 0 August 17th 08 08:16 AM
Update info from website to worksheet automatically, w/o opening s Juliana Excel Discussion (Misc queries) 0 March 5th 08 02:54 PM
Our new website Ewho New Users to Excel 0 February 8th 08 11:17 PM
Our new website Ewho Excel Discussion (Misc queries) 0 February 8th 08 11:17 PM
Our new website Ewho Links and Linking in Excel 0 February 8th 08 11:17 PM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"