Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2007, 03:20 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I access a Web page by Internet Explorer

Dear All!

With VBA I want to do all steps below:

Access my Web page using by Internet Explorer
Choose an Item (from list box) inside opening web page and then choose a command button

For example With VBA
1/I want to access web page from Internet Explorer: (http://p2p.wrox.com/forum.asp?FORUM_...sc&whichpage=1)
2/Choose: the last 2 days (from list box at left end of the page above)
3/Choose: Go (from list box at left end of the page above)

Many thanks

NC Hoang




 
Old August 17th, 2007, 09:52 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You do need to know the name of the element or it's array number to access it. This code assumes you click a button called CommandButton1:
----------------------------------------------------------------
Private Sub CommandButton1_Click()

'Requires Microsoft Internet Controls reference (Tools > References from code window)
  Dim ieBrowser As InternetExplorer, sSite As String
  sSite = "http://p2p.wrox.com/forum.asp?FORUM_ID=72&sortfield=lastpost&sortorder =desc&whichpage=1"
  Set ieBrowser = CreateObject("InternetExplorer.Application") 'Open IE instance
  ieBrowser.Navigate sSite 'Open page
  ieBrowser.Visible = True
  Do While ieBrowser.ReadyState <> READYSTATE_COMPLETE 'wait for page to load
    DoEvents
  Loop
  ieBrowser.Document.Forms("DaysFilter").Elements("D ays").Value = 2
  ieBrowser.Document.Forms("DaysFilter").Submit

End Sub
----------------------------------------------------------------

Hope this helps point you in the right direction. You can change when the browser is 'visible' or never make it visible. If you don't make it visible make sure to close it in your code.

 
Old December 6th, 2007, 12:42 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Allenm !
Your solution is great.
1/How can I get some information that I want (eg. some lines) contained in a webpage.
2/Can We read all page and store it in a variable.
3/How to use Mozilla Firefox (in new tab when it is opened) instead of Internet Explorer to open webpage

Regards

 
Old December 7th, 2007, 12:53 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

1) You would have to know the object name to pull from (document.name/id.innerHTML) or parse it yourself from the whole page/section based on tag(s).

2) Try either ieBrowser.Document.Body.innerTEXT or ieBrowser.Document.Body.innerHTML if you wish to preserve the tags.

3) Sadly you can't instantiate Mozilla Firefox with Microsoft VBA, only Microsoft IE. It should be clear why. You can, if you wish to deal with windows/handlers and their idiosyncrasies, use in combination the Shell command, passkeys and timeouts to grab body content. It's just not as convenient nor can you be specific as to what gets 'grabbed' but that means you can't do anything else while the computer is doing this or it won't work. It also can be buggy since you can't explicitly detect when the page is done.

Does this answer the question(s)?

 
Old December 10th, 2007, 04:20 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank for your kindly help. I try it now.

 
Old December 10th, 2007, 04:35 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great, it's the answer i'm looking for.

 
Old March 7th, 2008, 03:42 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 Hi Allenm !
Please advise me some following questions.

1/How can I reload a opening page (open with ieBrowser.Navigate sSite code) every 5 seconds to get latest information by VBA.
2/How to close a opening page.
3/Please advise a web_page that teach VBA code complied with internet explorer

Regards.

 
Old March 11th, 2008, 04:42 AM
Authorized User
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

Can we know a page load successfully or have an error when loading? Is there any parameter to make VBA detect a page loads with error

Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting info from Internet Explorer into Access AstridVM Access VBA 2 November 2nd, 2007 09:15 AM
Internet Explorer cannot open the internet site cathiec ASP.NET 2.0 Basics 1 October 22nd, 2005 01:30 PM
Internet Explorer JelfMaria VB How-To 10 April 27th, 2005 03:58 PM
Access Internet Explorer via Excel VBA tony_813 Excel VBA 2 March 6th, 2005 08:20 PM
vba and internet explorer ken1978 VB How-To 0 January 23rd, 2005 09:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.