Toad World® Forums

Automating Complex Excel Reports

Subject stolen shamelessly from Debbie’s post here: http://www.toadworld.com/Blogs/tabid/67/EntryId/628/Automating-Complex-Excel-Reports-new-in-version-2-7.aspx

I’ve set up my template file and macro as well as the pivot table - all works as I think it should.

But, here’s the rub - after exporting the data, I need to save the file individually - each day will have it’s own file, instead of constantly overwriting the template, and I’m not sure how to accomplish that. I also need to, if possible, convert the file to something over than .xlsxm as we’ve got a very paranoid Exchange server and it’s likely to delete the attachment.

If anyone has any suggestions, I’m all eyes :slight_smile:

I am working in the 3.1 Beta code and when I test this you can use the append time stamp and it will give you a unique name. It still needs to be a xlsm file, otherwise Excel can't open it properly. I think this was something we fixed in this code base so may not work in your version. TDA 3.1 will be GA first week of April.

Debbie

Is there anyway to customize the date/time stamp like I can when I define a variable in automation? I’m asking, because I’ve used that option before, and it goes something like this:

filenameDDMMYYYY HHMMSS.xlsx

The run-together filename is going to drive people nuts. While I personally don’t care, if it drives them nuts, they drive me nuts :slight_smile:

And what part did you think was fixed - the requirement for the xlsm file, or the date/time stamp?

The datetime stamp is fixed in the next release.

To accomplish the date format you want, set an automation variable and then use the automation variable in your filename. To do so, append it to the file name but dereference the variable name with the '#' symbols. See screenshot.

Debbie

It looks like some things have changed with the Export Wizard activity between 2.7 (when your guide is written) and 3.0 (what I’m running).

Specifically, the Export Wizard activity wants me to create a template if I’m not using an existing one (obviously I’m not), and it wants me to export something - but your guide has me using the Select to File activity to export my data, not the Export Wizard - so I’m not sure what to tell it to export.

Additionally, after selecting my .xlsm file, and getting to the Before Export/After Export macro options - it doesn’t show the macro in the Excel file. I re-opened the Excel file to make sure it’s still there, and it is, but TDA can’t see it for some reason.

Any ideas?

In the example I was showing how to use both the expert wizard and select to file activities with xlsm files. In order to fire a macro you have to use the export wizard activity. This activity always uses a saved template so you will need to go throught the wizard, set when to fire the macros and save to disk. If you only want to fire a macro then write a query that does not return any rows.

RE: not seeing the macros, I am not sure what is occuring there. I would try our 3.1 Beta. If you still have the issue in our Beta please send me a copy of your file and we can take a look.

Debbie

I understand - I really only need to use the Export Wizard then, as it accomplishes both tasks.

I used the 3.1 Beta, and I’m getting an error message when I get to the Macro select (3.0 doesn’t display any error messages when it doesn’t show the macros). The error is:

“Programmatic access to Visual Basic Project is not trusted. Please enable this feature in Excel in order to allow the execution of macros.”

In Excel I’ve enabled all macros, as you outlined in your blog post. Is there something else I need to enable?

Debbie Peabody wrote:

In the example I was showing how to use both the expert wizard and select to file activities with xlsm files. In order to fire a macro you have to use the export wizard activity. This activity always uses a saved template so you will need to go throught the wizard, set when to fire the macros and save to disk. If you only want to fire a macro then write a query that does not return any rows.

RE: not seeing the macros, I am not sure what is occuring there. I would try our 3.1 Beta. If you still have the issue in our Beta please send me a copy of your file and we can take a look.

Debbie

I figured out how to enable the Programmatic access. 3.1 sees the Macro, 3.0 still doesn’t for some reason (even after enabling the Programmatic access in Excel). This is somewhat frustrating :slight_smile:

Is 3.1 mature enough to put into production for automated reporting? I know it’s still a beta license and I probably won’t be able to swap over to the Enterprise license until GA in the first week of April, but I don’t have that long (our Microstrategy DW goes away 4/1) and I’m being pushed to automate as much as possible.

N.B. wrote:

I understand - I really only need to use the Export Wizard then, as it accomplishes both tasks.

I used the 3.1 Beta, and I’m getting an error message when I get to the Macro select (3.0 doesn’t display any error messages when it doesn’t show the macros). The error is:

“Programmatic access to Visual Basic Project is not trusted. Please enable this feature in Excel in order to allow the execution of macros.”

In Excel I’ve enabled all macros, as you outlined in your blog post. Is there something else I need to enable?

Debbie Peabody wrote:
In the example I was showing how to use both the expert wizard and select to file activities with xlsm files. In order to fire a macro you have to use the export wizard activity. This activity always uses a saved template so you will need to go throught the wizard, set when to fire the macros and save to disk. If you only want to fire a macro then write a query that does not return any rows.

RE: not seeing the macros, I am not sure what is occuring there. I would try our 3.1 Beta. If you still have the issue in our Beta please send me a copy of your file and we can take a look.

Debbie

Yes, it is stable to use. In fact, we are only making changes to the code up until the 15th and there are no outstanding changes for import or export.

Debbie