| |

Automatically Open Excel and Send Report Using Batch and VBA

 

We can use Visual Basic codes to automate some reports in Excel. Below are some simple codes to do this.

First this is a batch file to open our Excel report called “data report.xlsm”, assuming the report file is in the same folder as the batch file. You can schedule the time this batch file is called using Windows Scheduler .

 

This calls some functions if the opened ActiveWorkBook is called “data report” and the extension is “xlsm”

 

This clears the original data in the report and inserts a fresh new table data into a Sheet named “cityData” and then saves the entire workbook afterwards. The Excel sheet is already connected to Sql Server database which populates the table with information

This refreshes all sheets in the WorkBook.

 

This sends email to recipients after workbook is saved

This closes the entire Excel after we have emailed the workbook

Below is our sample generated table report which is being sent automatically using VBA code

inserted-report-and-data-being-emailed

Want more information like this?

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *