0
votes

I have created some macros to do some SQL queries into the data-base. My problem comes when I try to create a macro to define the connection. Macro recorder doesn't give any answer and none of the posts I have seen on the internet seem to help me. I need a macro to define the IP of the server and to give the user and password credentials.

Do any of you have any idea or can send a link to a webpage that explain how this can be achieved?

Thank you very much!

1
check on www.connectionstrings.com which works for ADODB but should work for Excel connections, too. - Kazimierz Jawor
Thank you. Which of all these examples do you think should I use to implement it in my VBA macro? - Martin Router King
on the front page search for provider, and next search for the scenario which is closest to your situation. - Kazimierz Jawor
Thank you to both of you for your help and scuse me for the duplicate. I couldn't find any related post before. - Martin Router King

1 Answers

0
votes

Is this what you are trying to do? This works for me. Just keep in mind you have to switch out the right fields.

Public Const pathName As String = "Driver={Microsoft ODBC for Oracle};" & _
                            "SERVER=serverName;UID=usernameHere;PWD=passwordHere"