Executing VBA From T-SQL

  • I am trying to find a way to execute VBA from within T-SQL.

    More specifically, I have a stored procedure that creates an excel file as its output. I also have a macro that is applied to the excel file in order to apply the proper formatting before the spreadsheet is disseminated. I am trying to find some way to automatically run that macro against the new file from within the SQL stored procedure.

    Any help that can be offered is appreciated.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Why not just make it an auto-exec macro that get's executed when the spreadsheet is opened?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • That is a good idea, but the security settings on Excel default to disabling macros and of course the user will then see the macro running. If there is a way, I would greatly prefer to have it formatted and macro free when it goes out the end users.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Create a formatted spreadsheet... use it as a template... use VBS to copy it to a new file... use OPENROWSET to populate the new file.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply