Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Filling out usernames in IE

As Paul D mentioned earlier, it is possible to launch IE from within VBA
(Code at the end)

Is it possible to input a username as well?

I am most interested on this one.

I know how to do it with Visual Basic Express and the webbrowser control,
but that is not good because I do not want to recreate a new browser, I want
to use IE.


Thanks,

Antonio

Public Sub CheckIE()
Dim objSW As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Dim objDoc As Object
Dim bAppRunning As Boolean

'Set objSW = New SHDocVw.ShellWindows
If objSW.Count Then ' new
For Each objDoc In objSW
If InStr(1, objDoc.LocationName, "Google") Then
bAppRunning = True
objDoc.Visible = True
Exit For
End If
Next objDoc
End If
If bAppRunning = False Then
Set objIE = CreateObject("InternetExplorer.Application") ' new
objIE.Visible = True
objIE.Navigate "www.google.com"
End If

Set objIE = Nothing
Set objSW = Nothing
End Sub

Paul D

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default Filling out usernames in IE

Antonio wrote:
As Paul D mentioned earlier, it is possible to launch IE from within VBA
(Code at the end)

Is it possible to input a username as well?


You just have to be able to find out how to fill in the username. For
example, I have an EXCEL spreadsheet I use to create portfolios on
Yahoo! that fills in the forms iteratively. The routine below is used
to find the FORM on the page, then to fill in each item of the FORM,
then CLICK on the save option of the FORM. It does this until my list
of transactions is at an end. Here's the routine:

Sub YahooAddPortfolioTransactions()
Set oForm = oIE.Document.forms(0)
For Each oCell In Sheets("Yahoo! Portfolio
Transactions").Range("A2:A500")
If oCell.Value = "" Then Exit For
oForm("y").Value = oCell.Offset(0, 0)
oForm("m").Value = oCell.Offset(0, 1) - 1
oForm("d").Value = oCell.Offset(0, 2)
oForm(".act").Value = oCell.Offset(0, 3)
oForm(".sym").Value = oCell.Offset(0, 4)
oForm(".units").Value = oCell.Offset(0, 5)
oForm(".unitprice").Value = oCell.Offset(0, 6)
oForm(".comm").Value = oCell.Offset(0, 7)
oForm(".note").Value = oCell.Offset(0, 8)
oForm(".save2").Click
Do: DoEvents: Loop While oIE.Busy
Do: DoEvents: Loop Until oIE.ReadyState = READYSTATE_COMPLETE
Set oForm = oIE.Document.forms(0)
Next oCell
oForm(".cancel").Click
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Filling out usernames in IE

Hi Randy,

That looks most promising.

1. What is oCell? it looks like a cell but I am not sure. Do you dim it
earlier?

2. What references do you have other than MS Internet Control?

3. How does the code execute? You open IE, navigate to your address and then
run the code? The Set oForm = oIE.Document.forms(0) sets the forms from the
web page I guess

4. How do you find the names of the oForms in the page? I guess you go in IE
to View/Code and then?

Sorry for all the questions.

Many thanks, again, this can be very helpful.

Antonio


"Randy Harmelink" wrote:

Antonio wrote:
As Paul D mentioned earlier, it is possible to launch IE from within VBA
(Code at the end)

Is it possible to input a username as well?


You just have to be able to find out how to fill in the username. For
example, I have an EXCEL spreadsheet I use to create portfolios on
Yahoo! that fills in the forms iteratively. The routine below is used
to find the FORM on the page, then to fill in each item of the FORM,
then CLICK on the save option of the FORM. It does this until my list
of transactions is at an end. Here's the routine:

Sub YahooAddPortfolioTransactions()
Set oForm = oIE.Document.forms(0)
For Each oCell In Sheets("Yahoo! Portfolio
Transactions").Range("A2:A500")
If oCell.Value = "" Then Exit For
oForm("y").Value = oCell.Offset(0, 0)
oForm("m").Value = oCell.Offset(0, 1) - 1
oForm("d").Value = oCell.Offset(0, 2)
oForm(".act").Value = oCell.Offset(0, 3)
oForm(".sym").Value = oCell.Offset(0, 4)
oForm(".units").Value = oCell.Offset(0, 5)
oForm(".unitprice").Value = oCell.Offset(0, 6)
oForm(".comm").Value = oCell.Offset(0, 7)
oForm(".note").Value = oCell.Offset(0, 8)
oForm(".save2").Click
Do: DoEvents: Loop While oIE.Busy
Do: DoEvents: Loop Until oIE.ReadyState = READYSTATE_COMPLETE
Set oForm = oIE.Document.forms(0)
Next oCell
oForm(".cancel").Click
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default Filling out usernames in IE

1. What is oCell? it looks like a cell but I am not sure. Do you dim it earlier?

It's just a single cell created by the iteration of:

For Each oCell In Range(....)

2. What references do you have other than MS Internet Control?


I think that's the only one needed, but I'm not sure. I have a number
of add-ins, so I can't unallocate the references that are in use.

3. How does the code execute? You open IE, navigate to your address and then
run the code? The Set oForm = oIE.Document.forms(0) sets the forms from the
web page I guess


I have another routine I run to do that. This was just an experiment I
ran to see if I could fill in the forms from my spreadsheet. I ran
this routine first:

Dim oIE As InternetExplorer
Sub OpenIE()
Set oIE = New InternetExplorer
oIE.Visible = True
End Sub

Then I manually navigated to the Yahoo! page where I add portfolio
information. Then executed that routine which enters the information,
clicks to continue, and repeats until at end of the data within the
iterating range.

4. How do you find the names of the oForms in the page? I guess you go in IE
to View/Code and then?


Correct.

However, once you have done the OpenIE() routine above, you can also
use the VBA watch function to navigate the oIE object. You should be
able to find the forms and its elements there as well. Between the
source code and the watch list, it's pretty easy to find everything.

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
tracking changes and showing usernames Jim Excel Worksheet Functions 1 December 18th 06 10:34 PM
usernames and passwords shannyshanhan Excel Worksheet Functions 2 August 7th 06 09:13 PM
Multiple Application.UserNames Bob Excel Discussion (Misc queries) 4 May 15th 06 06:19 PM
Clear stored usernames Brent E Excel Discussion (Misc queries) 1 November 23rd 05 11:37 PM
to add new usernames seanyeap Excel Programming 4 January 5th 04 10:55 AM


All times are GMT +1. The time now is 12:50 AM.

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

About Us

"It's about Microsoft Excel"