We help IT Professionals succeed at work.

Embedd Password in Excel

Mark Harris
Mark Harris asked
I have an excel workbook with 7 sheets in it.  The data in all the sheets is extracted from an ODBC connection with a DB user and password.

Each time the workbook is opened, the last set of data extracted is shown, obviously.  If I need to refresh the data, I am required to put in the DB user and password for each page.

All the data is coming from the same DB so the password is the same for all 7 sheets.

I would like to know if there is a way to embed the user and pass into the workbook so that each time I refresh the data, the user and password are passed through without any need to type it in.

I was actually thinking that it would be nice to have the user and password, passed through to the DB when opening the sheets so that there is never a need to refresh the data after opening.

Is this possible?

Mark the fireman
Watch Question

I think if you define the connection string with the login credentials it will know the UN and PW when refreshing. As far as refreshing upon opening, read below.

The following was quoted from MS website (http://office.microsoft.com/en-us/excel-help/refresh-connected-imported-data-HP010087045.aspx)

You can refresh an external data range automatically when you open the workbook. Optionally, you can save the workbook without saving the external data so that the file size of the workbook is reduced.

1.Click a cell in the external data range.
2.On the Data tab, in the Connections group, click the arrow next to Refresh, and then click Connection Properties.
3.Click the Usage tab.
4.Under Refresh control, select the Refresh data when opening the file check box.
5.If you want to save the workbook with the query definition but without the external data, select the Remove data from the external data range before saving the workbook check box.

If you check "use Trusted Connection", you don't need to type in the login ID and password.

You can use refresh all to refresh all the data. The refresh all command is under Data tab, connections group in Excel 2010.
I believe trusted connections are only if the DB you are using has windows authentication available. If the DB does not support windows authentication, then you will need to modify the connection string to include the username and password.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.