Change Connection using VBA

tlindeman

Active Member
Joined
Jun 29, 2005
Messages
313
Is it possible to edit an existing connection (called Invoices) and change the command text to equal a paste special? I am recording a macro to connect to a SQL database and I need to be able to change the command text to a different date each time. I can set it up in excel, I just get stuck on how to change the comman text in VBA. If you need more information , let me know.

Thank You
Tony
 
Perfect thank you very much, I was on the right track, I just used dim MYVALUE as object and it failed. In any case I really appreciate your help.

Tony

Hola,

I´m doing something similar in regards a project I have with vba, but I would like to retrieve the result of .commandtext to a specifi Cell

something like Sheets("Sheet1").Range("G1").value= .Commandtext = "Select top 1 data From Orders"

Any help would be really appreciated.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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