Solved

Passing user name and password with VBA to intranet log-in

Posted on 2011-03-02
7
668 Views
Last Modified: 2012-06-27
I have several processes that take about three hours to run.  Right now, the user needs to log onto the intranet, enter their credientials to get to the underying reporting package.  Since most of the users have their credientials "remembered", is there a way to do a SendKEy of some sort with VBA to OK the dialog box so the code can run, that is, get the excel worksheets from the intranet and downloaded into the local file?  I would like to run this process around 6:00 am, but this manual OKing of the log in data stops this.
0
Comment
Question by:ssmith94015
7 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35021072
I am sure it can be done using Windows APIs. I wouldn't recommend Sendkey though as it is highly unreliable.

Please tell me more about this intranet site? What is the caption of the window? A screen shot as well?

Sid
0
 

Author Comment

by:ssmith94015
ID: 35021468
Hi Sid.  This is a site where all the client monthly base data information is held.  The VBA Excel process takes these 160 reports, puts them all in one master workbook local to the user and from there the client's individual reports are created.  These master workbooks hold the history as once the month is over, the data on the intranet is destroyed and a new month's data is available.  Only the URL to each of the Excel workbooks on the site is used, there actually is no user interface, it is only a pointer to the workbook on the intra net, this pointer is located in the VBA Excel workbooks that is used to process and only opens workbook once the URL is processes.  However, to get to the intranet site, login creditional must be passed.  Sorry, no screen shots as confidential data.  The log in is the same as the user's machine log in so I was hoping that may provide help.
0
 
LVL 12

Expert Comment

by:sdwalker
ID: 35021519
If it were a database, you could use Windows NT Authentication.  I could definitely be wrong, but I don't think Microsoft is going to write an API or something that allows you to retrieve the user's password.  It seems like that would be too scary of a security threat.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35021544
>>>Sorry, no screen shots as confidential data.

Well, with this little info, we don't have much to proceed on. However, lets talckle it in a different manner. When you say intranet, What kind of user interface are we talking about. You mentioned 'sendkey' so apparently there is a 'window' where you need to send them. You could use the FindWindow API to find that window and then either use SendMessage/PostMessage API to download your files.

Visit this link for info in APIs

http://allapi.mentalis.org/apilist/apilist.php

Sid
0
 

Author Closing Comment

by:ssmith94015
ID: 35021850
Yes, I know there is so little, but I think you are correct.  The logon dialog box appears, but then as I was thinking, it appears four times during the processing, but I am going to investigate the APIs.
0
 
LVL 6

Expert Comment

by:TinTombStone
ID: 35022050
This is what I use to log-on to my mail account.

Now this deals with main window fields not pop-ups so I don't know if it will work.

but give it a go, change the details, it may be a starting point

Dim HDoc As HTMLDocument
Sub WebsiteLogon()

Dim htmlElement As IHTMLElement
Dim Url As String

On Error GoTo Err_Handler
   
    Url = "https://login.yahoo.com"
   
    Set browser = New InternetExplorer
    browser.Silent = True
    browser.navigate Url
    browser.Visible = True
   
    Do
    Loop Until browser.ReadyState = READYSTATE_COMPLETE
   
    Set HDoc = browser.Document
   
    HDoc.all.Email.Value = "sample@yahoomail.com"
    HDoc.all.passwd.Value = "xxxxxxxxxx"
   
    For Each htmlElement In HDoc.getElementsByTagName("input")
        If htmlElement.Type = "submit" Then htmlElement.Click: Exit For
    Next
   
Err_Handler:
    If Err <> 0 Then
        Debug.Assert Err = 0
        Err.Clear
        Resume Next
    End If
End Sub
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35022076
>>The logon dialog box appears, but then as I was thinking, it appears four times during the processing, but I am going to investigate the APIs.

Sure. Let me know if you get stuck. Any chance of posting the snapshot of the Logon Window. I am sure that won't have any confidential data?

Sid
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now