Reputation: 21
I have 10 Excel files that are connected to a SQL Server by OLEDB and I need to refresh them everyday one by one manually. When I refresh them I need to insert a password. I tried to make a macro to automate this process, but I didn't succeed. I did this function to automate one of my workbooks:
Sub updateABC()
Workbooks("Teste").Connections("SQL Server_Azure1").OLEDBConnection.Refresh
End Sub
And the Excel ask for the password to SQL Server logon. Is there any way to put this password automatically using vba?
Thanks.
Upvotes: 2
Views: 7053
Reputation: 13
There is a way in Excel without VBA:
Do the same for all of your connections
You can then refresh all connections and you will be prompted to enter the password for each connection. Once you do this and save the document it will not ask you for your passwords again.
You can also tick "Refresh data when opening the file" on the Usage tab to have the connections refreshed when the workbook is opened.
Upvotes: 1