?
Solved

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

Posted on 2011-03-02
7
Medium Priority
?
707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

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