Solved

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

Posted on 2011-03-02
7
682 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

726 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