Hyperlink to Website - Passing Username and Password

JohnCM

New Member
Joined
Sep 4, 2008
Messages
43
Is there a way to use a hyperlink to a website in VBA which will pass the username and password required by the website?

The URL I am using is going to a secure site, which requires a username and password, to download a csv file. Currently when I follow the hyperlink a popup authentication window opens which stops the macro until the users enters in the values needed. An additional popup then occurs asking if the file should be opened in excel.

I would like to be able to pass the needed credentials without having to compel the user to intervene. Is this possible using the hyperlink method?

Are there other ways to access a csv file for download from a URL?

John Martinez
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I'm not certain how the PWD will intercat with this method, but have you tried the WinAPI URLDownloadToFile?

Function Declaration:
Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
        (ByVal pCaller As Long, _
        ByVal szURL As String, _
        ByVal szFileName As String, _
        ByVal dwReserved As Long, _
        ByVal lpfnCB As Long) As Long

As far as populating the uname and pwd, it should be possible to determine the Windows Handle of the new popup, capture it and automate it using teh Internet Explorer Object Model Library. However, this method is tricky, and time consuming to get right. If I remember correctly, you;ll need about a half-dozen different API calls to get it right. Alternatively, you may be able to make the SendKeys Function work, though it tends to be quite unreliable, in my experience.
 
Upvote 0
Not familiar with the use of API or the Internet explorer library. What is this WinAPI trying to do? Are there any other lines of code after the Function Declaration? Do I call the Function from Visual or from excel?

Are any of properties of the Hyperlink method intended for this purpose? The MSDN instructions on the method leave something to be desired.

Thanks,

John M.
 
Upvote 0
Not familiar with the use of API

API = Application Programming Interface.

I know enough to be dangerous. Basically, WinAPI calls allow you to call functions from the Windows Operating System Libraries, among other things. The idea is that you declare to the VBA Engine what Function you wish to call from what file/library, as well as it's input/output parameters. What I listed in my previous post is this declaration, as it would appear in a standard VBA Module.

Here is an example of the usage, it will download teh MrExcel Articles Page File to your Temp Folder (assuming that the Board Software doesn't completely bowdlerize the address for security purposes...):

Rich (BB code):
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
        (ByVal pCaller As Long, _
        ByVal szURL As String, _
        ByVal szFileName As String, _
        ByVal dwReserved As Long, _
        ByVal lpfnCB As Long) As Long
   
Sub Download()
   Const URL_File As String = "http://www.mrexcel.com/articles.shtml"
   Const Down_Load_Folder As String = "c:\temp\dl.html"
        
    URLDownloadToFile 0, URL_File, Down_Load_Folder, 0, 0
        
End Sub

or the Internet explorer library.

Here is a thread where I have a post demonstrating how to use the Internet Explorer Object Library to automatically make some website selections. Of course, it gets much more difficult if you need to capture a new instance of IE that spawns as teh result of a button clisk... difficult, but not impossible. This Article talks about instancing of IE objects.
 
Upvote 0
Hatman,

Thank you for the example and the discussion. I will delve into the world of API as it sounds fascinating.

Thanks for opening my eyes to a new venue of tools.

JM
 
Upvote 0
Hatman,

Thank you for the example and the discussion. I will delve into the world of API as it sounds fascinating.

Thanks for opening my eyes to a new venue of tools.

JM

You are welcome. As I mentioned, this may not be the panacea it appears to be at first glance. I believe that this API uses a protocol other than HTTP, which means that in some cases, it can bypass certain types of security. However, many other types of security will prevent this direct download method. If it is the case that the security does in fact prevent this API download (most likely, IMO) then automation of teh IE session is probably your best bet...
 
Upvote 0
I am trying to do something similar. The difference is they my Hyperlink is for Search Customer Code in our User Management System (backend). When I copy and paste the link in the chrome it works, but when I am clicking on Hyperlink it asks me to login (after login it just doesn't search):confused::confused:

This is my Hyperlink:
=HYPERLINK("https://ew.dptechnology.com/ew/sw/swcd.asp?ID="&E15,E15)

This is the URL, which I want to display without login:
https://ew.dptechnology.com/ew/sw/swcd.asp?ID=MAHA33464

Thanks In advance for answers.
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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