Never been tried?

MiskaTorn

Board Regular
Joined
Mar 30, 2004
Messages
155
I actually have no use for the function yet, but may in the future, and I was playing around with a few functions in VBA and seeing if it could be done but I was stopped hard and faced with the reality that it might not actually be possible.

But my curiosity has the better of me and I am forced to ask the brains of this community if anyone knows how to do this.

Say you have a file

Firstname, Lastname, Email

Then there was a web page collecting the info in a form.

Would there be a way to use those cells to prepopulate the form and the submit it?

I was playing around with the idea of loading it as an image tag.

and just filling in the fields with the variables. Anyways, just thought it'd be interesting.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Wow..yes...very very close indeed..in fact 99%...now the only problem I would see.

If you have a file of like 50 names.

Is there a way to closer the browser windows?
 
Upvote 0
If you know how to either create an array from the range in question or loop through a range, do that and pass your variables here:

.UserName.Value = rangeVar1.value
.password.Value = rangeVar2.value
.login.Click

To kill it, change

.Visible = True

to

.Quit

Edit: Typo
 
Upvote 0
Now that is brilliant. Thank you very much for shedding light on that...quick resolution to a problem that would've botherd me forever :)
 
Upvote 0
You are welcome.

Also, loop within the same Internet Explorer Object, no need to initialize and terminate the object 50 times eh (overhead). :wink:
 
Upvote 0
I was trying this out.....how exactly do you use this macro?

Sorry for beng dum at this...

Code:
Public Declare Function ShowWindow& Lib "user32" _
    (ByVal hwnd As Long, ByVal nCmdShow As Integer)

Private Sub LoginMrExcel()
Dim ie As Object
On Error GoTo 1
Set ie = CreateObject("InternetExplorer.Application")
With ie
    .navigate "http://www.mrexcel.com/board2/login.php"
    Do While .busy: DoEvents: Loop
    Do While .ReadyState <> 4: DoEvents: Loop
    With .Document.Forms(0)
        .UserName.Value = "Mr. Excel Login Name"
        .password.Value = "Respective Password"
        .login.Click
    End With
    Do While Not CBool(InStrB(1, .Document.url, "index.php"))
       DoEvents: Loop
    Call ShowWindow(.hwnd, 3) 'Maximize
    .Visible = True
End With
Set ie = Nothing
Exit Sub
1:  MsgBox "Unexpected Error, sorry."
    ie.Quit
    Set ie = Nothing
End Sub

Sub test()
Dim WScript As Object
Set WScript = CreateObject("WScript.Shell")
WScript.Run "IExplore.exe http://www.mrexcel.com"
Set WScript = Nothing
End Sub

To me it looks like there is something missing.

When it is run I get a compile error
 
Upvote 0
You need to change the values your passing to form. It'll create a new ie instance and log you into MrExcel.com. You don't need the 2nd procedure. See my comments:

<font face=Courier New><SPAN style="color:darkblue">Public</SPAN> <SPAN style="color:darkblue">Declare</SPAN> <SPAN style="color:darkblue">Function</SPAN> ShowWindow& <SPAN style="color:darkblue">Lib</SPAN> "user32" _
    (<SPAN style="color:darkblue">ByVal</SPAN> hwnd <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>, <SPAN style="color:darkblue">ByVal</SPAN> nCmdShow <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>)

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> LoginMrExcel()
<SPAN style="color:darkblue">Dim</SPAN> ie <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
<SPAN style="color:darkblue">On</SPAN> <SPAN style="color:darkblue">Error</SPAN> <SPAN style="color:darkblue">GoTo</SPAN> 1
<SPAN style="color:darkblue">Set</SPAN> ie = CreateObject("InternetExplorer.Application")
<SPAN style="color:darkblue">With</SPAN> ie
    .navigate "http://www.mrexcel.com/board2/login.php"
    <SPAN style="color:darkblue">Do</SPAN> <SPAN style="color:darkblue">While</SPAN> .busy: DoEvents: <SPAN style="color:darkblue">Loop</SPAN>
    <SPAN style="color:darkblue">Do</SPAN> <SPAN style="color:darkblue">While</SPAN> .ReadyState <> 4: DoEvents: <SPAN style="color:darkblue">Loop</SPAN>
    <SPAN style="color:darkblue">With</SPAN> .Document.Forms(0)
        .UserName.Value = "Your Login ID" <SPAN style="color:green">'Change to YOUR Login ID</SPAN>
        .Password.Value = "Your Password" <SPAN style="color:green">'Change to YOUR password</SPAN>
        .login.Click
    <SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
    <SPAN style="color:darkblue">Do</SPAN> <SPAN style="color:darkblue">While</SPAN> <SPAN style="color:darkblue">Not</SPAN> <SPAN style="color:darkblue">CBool</SPAN>(InStrB(1, .Document.URL, "index.php"))
       DoEvents: <SPAN style="color:darkblue">Loop</SPAN>
    <SPAN style="color:darkblue">Call</SPAN> ShowWindow(.hwnd, 3) <SPAN style="color:green">'Maximize</SPAN>
    .Visible = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
<SPAN style="color:darkblue">Set</SPAN> ie = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Exit</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
1:  MsgBox "Unexpected <SPAN style="color:darkblue">Error</SPAN>, sorry."
    ie.Quit
    <SPAN style="color:darkblue">Set</SPAN> ie = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>
</FONT>
 
Upvote 0
Hiya Nate,

If a feller wanted to try and early bind on the IE object, what reference would one look for? I found one for Microsoft HTML Object Library (C:\WINNT\system32\MSHTML.TLB on Win2000 OS) that appears to have some of the properties and methods you hit. But I'm not sure that it's the same critter.

As ever, thank ya kindly for any knowledge you'd care ta share.
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,365
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top