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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,214,801
Messages
6,121,644
Members
449,045
Latest member
Marcus05

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