Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002

    Unanswered: Run macro through Excel ODBC connection

    Is there a way to run an excel macro through an Excel ODBC Connection?
    i.e. Connect to an excel workbook using ODBC and then execute a command that will run a macro.
    Any help really appreciated!

  2. #2
    Join Date
    Feb 2004
    If you are accessing an Excel file by ODBC, you are only retrieving data. It is not really possible to directly activate a process in the data file you are accessing the data from. Supposing you want to do something to the data using a macro. You can retrieve your data by a database query using ODBC or preferably ADO into a dataset. Then write the data to a target Excel worksheet. Then run the a macro to take action on the data once it is written to the worksheet.

    Another scenario would be to run a query on your file and based on the results take an action to run on the data file. Then close the data connection and run a process to open the file run a procedure on the file, and close it. You could do this while screen updating is false or while the focus is off the file so it does not display the workbook being opened or show the script actions. You would not activate the macro from the data connection but could simulate it this way.
    Last edited by savbill; 08-03-07 at 21:32.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts