Help to automate login process "in a web query"

Lplater

Board Regular
Joined
Apr 6, 2013
Messages
107
Hey guys, first time poster and hoping for some genuine vba guru assistance to a "final hurdle" I have with a workbook I'm working on which will be used solely "at work" on a company "intranet" as opposed to the general internet persay.




I can, "when at work", manually login my workbook in to company servers to extract "live" data via the use of web queries but badly wish to "eliminate" the need for "the user" to "login" to company servers each and every time the workbook is fired up.
Instead I wish to build a macro which supplies a "generic username and password" to the servers and automatically logs the user in and there in turn begins the auto update of web queries I have already built in to my sheet, based on the time intervals I have set in the query properties.


So far I have managed to build a macro in to my sheet which auto logs the user in to and opens a webpage on the company server. I did extract the necessary element id's etc from the webpage source info but so far am lost as to how to put this info in to a usable macro with which to enable my web queries to then auto update.


Basically, I want the macro to simply log the user in to a company server, "NOT" to open a webpage but simply so my sheet logs itself on the server in the background thereby enabling my queries to begin...


The usable info I used when making my ie macro were as follows: Please exscuse me if I have included script which is not required, but for security reasons also am a little reluctant to post entire page which is not normally visible to anyone "outside" my companyt without a valid login id and password.


If anyone at all can possibly help I would be extremely grateful,
Regards, Lplater




td class="paraContent"><input name="j_username" id="j_username" type="text">


td class="paraContent"><input name="j_password" id="j_password" type="password">


<input id="idHiddenButton" type="submit" value="" style="display: none; width: 0px;">
<span><a onfocus="this.***********()" title="Sign In" style="text-decoration: none;" ***********="window.status=this.title;document.getElementById('idButtonLoginText').className='largeButtonTextCellOn';return true;" **********="window.status='';document.getElementById('idButtonLoginText').className='largeButtonTextCellOff';" *******="*******_idButtonLogin();return false;" href="#" onblur="this.**********()"><table id="idButtonLogin" cellspacing="0" class="largeButton"><tbody><tr><td class="largeButtonImgCell"><img border="0" src="/maintenix/servlet/image/key.gif"></td><td nowrap="" id="idButtonLoginText" class="largeButtonTextCellOff">Sign In</td></tr></tbody></table></a><span style="display: none">.</span></span>******** type="text/javascript" language="Javascript">
<!--function *******_idButtonLogin() {buttonAction_idButtonLogin();}function buttonAction_idButtonLogin() { document.getElementById( 'idHiddenButton' ).click();}// -->
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Regards my first post, the usable info was as such:

"paraContent" input name="j_username" id="j_username" type="text"
"paraContent" input name="j_password" id="j_password" type="password"
"idHiddenButton" type="submit" value="" style="display: none; width: 0px;"
 
Last edited:
Upvote 0
I'm currenty working on something similar to that but with a UserForm. When I launch the Excel application, it automatically launches my UserForm. Heres the code that I'm currently using to do that. Try putting this in "ThisWorkbook", Save, then relaunch.

Sub TimerProc()

RunWhen = Now + TimeSerial(0, 0, 1)

If UserForms.Count = 1 Then
Application.OnTime RunWhen, Me.CodeName & ".TimerProc"
Else
Application.Visible = True
End If

End Sub


Private Sub Workbook_Open()

RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, Me.CodeName & ".TimerProc"
Application.Visible = False
UserForm3.Show

End Sub
 
Upvote 0
Thanks Taraus for your attempt or for even responding.
Not really sure how your code can help me though as although at a guess I'm assuming your "userform" opens an entry box where the user stipulates their username and password ???

Did try and run your code you posted but it results in a debug error which says "invalid use of Me keyword", needless to say I have no idea what this really means.

It's a pity I can't resolve this dilemma I have as I have seen litterally hundreds of similar posts all over the net dating back as far as 2004 but no one seems to know how to manipulate code to auto input a username and password for an iqy file to run.

My queries are not "written" via code and a module but rather "added directly" to a sheet via selecting my stipulated cell, selecting the data tab and right clicking "new web query" and then inputing a web addy and choosing my tables directly and then selecting "import".

The option in query properties dialog box to save my password is greyed out and hence am also not able to have the query "remember" the password etc.

I have thus far and easily been able to write code which passes on my username and passwords which opens an instance of ie but it's worth nothing to me if I can't achieve this to work "in a web query".

Any other suggestions are welcomed not just by your good self but especially from more learned excel gurus,

Cheers,

Jas
 
Upvote 0
90% sure I figured it out now. Managed to work with the code posted by coop from another site and now able to pull info from the pages I need.
Manipulated the code to work in unison with my login details. Now to build the other 200 odd query macros to call simultaneously.

If I have indeed sorted this out, will post my code for others to use as it's quite obvious many people wish to do something similar but get stuck where I have been,

jas
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,636
Members
449,043
Latest member
farhansadik

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