SlideShare a Scribd company logo
Automation of Reporting and Alerting
 
 
Microcosm The following presentation is an illustration of most of my automation techniques in one project. It is a microcosm of an automated set of systems I set up to; Illustrate and share data (in a secured location) Create audits (proactive and reactive) Trigger events (send emails)
Techniques Secured folders Utilization of folder security instead of Excel passwords ODBC Connections Creating real time links to the database tables of applications. Access queries Bringing data (tables) for one or many applications together. Calculations being performed. Excel Pivot tables Illustrating data on a user friendly interface. Excel Macros Automation of the updating of spreadsheets Automation of emails sent to the right people. Scheduled tasks Starting the macros, at night.
The project The project was to automate notifying employees (only certain exempt emps) to submit timesheets. An HR rep was doing this in the past (for her location) and she wanted a program that did this, without her having doing anything. The task was to set up pivot tables that illustrated 2 problems and with a summary and detail tab for each (4 tabs total). Pay periods that had no submitted hours. Pay periods that had hours, but hade never been submitted. Notifications were to be emailed automatically, every Tuesday morning.
Final Spreadsheet (summary tab)
Final Spreadsheet (detail tab)
Email Notification
Groundwork The groundwork for this project had already been laid by existing projects. The goal was just to copy existing molds and create new processes.
Folder security
Folder security In a shared location create a folder. Have your IT department create a security group on the folder. This replacing have an Excel password (and is more secure)
Folder security The folder I used, already had security and a variety of confidential excel spreadsheets
Access Engine
Access Engine Access is going to be the powerhouse behind the process. It will access the tables (ODBC) and manipulate the data (queries), so they can be illustrated in Excel (pivot tables)
ODBC connection
ODBC connection ODBC connections are read only links to your applications tables. Once your source is updated, your ODBCs will be. Some applications, the ODBCs, are created upon installation. Others you will need your IT team to create for you. These connections are similar to what a SQL programmer might work with (but read only).
ODBC connection 1 st  thing to do is access the data (tables) via an ODBC connection. I had already established these real-time links and researched what data was in what table and what their common denominators were. These tables were from our salaried timekeeping system (NetConsole)
ODBC connection Go to File Get External Data Link Tables If you select Import, it creates a static table, which is not automatically updated.
ODBC connection Change “Files of type:” to ODBC databases()
ODBC connection Select the Machine Data Source tab Select your database
ODBC connection A list of the tables will appear. Select the one you want. This might involve a lot of trial and error. I usually select all and find out what each one contains.
ODBC connection Here is one of the opened tables for my timekeeping system. Most tables have “IDs” that correspond with other tables. You will need to know what these mean, when you create queries. Most developers create relationships at the table level, but I prefer to do that at the query level (next set of slides).
Access Queries
Access Queries The way I create queries, is by selecting; Create query in Design view
Access Queries Select the tables of queries that you want to bring together
Access Queries I had already created a base timesheet query, for other projects. So I could copy that base one and use that.
Access Queries Once copied, select paste and name the new query
Access Queries All of these tables get linked together by their “IDs” or a common denominator. In the end, they become one unified set of data. There is a lot of trail and error in this process and validation to know values.
Access Queries Double click on the headers you want on you query.
Access Queries Add  criteria  to narrow the range of the query.
Access Queries Add formulas to perform your math. In this case I needed to change blanks caused by linking table and add create a total hours column. I used an IIF(IsNull) formula. It converts blank spaces to zeros, so that math can be performed.
Access Queries One of the tasks of the project was to find who hadn’t entered hours for a pay period. This isn’t tracked in our attendance system. This query assigned a period to every one. Example: John Doe has a row for every pay period, in all of the years for our time keeping system.
Access Queries By linking a query that has all of the timekeeping data, with one that assigns pay period regardless if worked. We now have a query, that tells us, you didn’t enter time
Access Queries Next is giving a value to hours entered and hours missing (per payperiod). We can track that on a pivot table and run macros off that data.
Excel Pivot Tables
Excel Pivot Tables Next is creating a pivot table that has sums of the pay periods missing, so an email can get generated.
Excel Pivot Tables To create a Pivot table Got to Data PivotTable and PivotChart Report
Excel Pivot Tables Select External data source Next
Excel Pivot Tables Select Get Data
Excel Pivot Tables Select MS Access Database
Excel Pivot Tables Navigate to folder location Select database
Excel Pivot Tables Select Table or query Arrow (to move all headers over) Next (next couple screens)
Excel Pivot Tables Select Finish
Excel Pivot Tables Select Next
Excel Pivot Tables Select Layout
Excel Pivot Tables Select Headers you displayed on the picot table Drag and drop Page area is a big filter Row and column area illustrate text and groups Data area does the math
Excel Pivot Tables Select Finish
Excel Pivot Tables A default view of your pivot will appear. I never use the default, so the next slides will show how to change it. At the same time a list of your header will appear. You can close these at any time.
Excel Pivot Tables If you don’t already have the pivot table toolbar, this would be a good time to add it. Select View Toolbars PivotTable
Excel Pivot Tables Select Format Report Scroll down and select Table1 You can experiment and choose which one you like better.
Excel Pivot Tables Once you change the report type, the rows and columns can get mismatched. You can go back to the layout, by right click on the pivot and selecting wizard. Or, you can pick up the header and drag it, to where you want it.
Excel Pivot Tables Most items are defaulted to give subtotals. Which could be what you and could be an eye sore. To turn off the sub totals Right click on the data for that column and select Field Settings
Excel Pivot Tables Change Subtotals to None
Excel Pivot Tables If you don’t space between lines. Click on Layout Deselect Insert blank line after each item.
Excel Pivot Tables I only needed a couple people for this process, which I can filter on the name header. Select the pull down arrow. Select (Show All). This deselects everyone. Select the names you need for this process.
Excel Pivot Tables This is the finished version for the summary. This tab will drive my macro. For the detailed tab, you don’t need to redo the pivot table process. You just need to create a copy of the tab. Right click on tab and select Move or Copy
Excel Pivot Tables Click Create a copy and Ok
Excel Pivot Tables Right click anywhere on the pivot. Select Field List
Excel Pivot Tables Drag and drop Period next to Supervisor. There will be a gray line that acts as a guide.
Excel Pivot Tables Drag and drop NonSub on the Page field. This allows you to select certain items. You can select Field settings and hide items (like the zero).
Excel Pivot Tables I selected one, so it would only illustrate, names with out pay periods. Which was none in this case.
Excel Pivot Tables This is the summary tab for employees that didn’t enter any hours for a pay period.
Excel Pivot Tables This is the detail tab, which illustrates; The supervisor and their employees that have pay periods with missing hours. I added back in the subtotal for supervisor and name headers.
Excel Macros
Excel Macros I usually create a blank spreadsheet to house my macros. Hit ALT F11 to open the VBA screen.
Excel Macros Create your code in a Module.  Or you can use the recorder to create your macros. I do that for some of my stuff, but emailing requires writing the code.
Excel Macros Sub Diebold_email_start() ' Application.DisplayAlerts = False Application.ScreenUpdating = False On Error Resume Next  'turn error reporting off Workbooks.Open Filename:="P:\Payroll\Anderson\Anderson_Billable.xls", Notify:=False If ActiveWorkbook.ReadOnly = True Then ActiveWorkbook.Close False Else Sheets("NotEntered_Master").Select Range("A4").Select ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh ActiveWorkbook.Save Range("C5").Select Dim x As Integer x = Range("C5") If x = 0 Then ActiveWindow.Close Else Application.Run "Anderson_Macro.xls!Diebold_email" End If End If Application.DisplayAlerts = True Application.ScreenUpdating = True On Error GoTo 0 'turn error reporting back End Sub Like in Access, I had macros that did what I wanted, I just needed to copy them and change some info (in the colored boxes). This macro; Opens the spreadsheet just shown . Refreshes the pivot table Checks to see if Diebold (C5 on the pivot table) has a sum greater than zero If it doesn’t it closes the spreadsheet If it does it launches another macro
Excel Macros Sub Diebold_email() Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "" & vbNewLine & vbNewLine & _ "You have not entered hours in NetConsole, for a prior period(s), please enter and submit these hours ASAP." & vbNewLine & _ "" & vbNewLine & _ "" & vbNewLine & _ "" On Error Resume Next With OutMail .To = "Brian.Diebold@inergyautomotive.com" .CC = "Brenda.Dutton@inergyautomotive.com; Mohammad.Muqri@inergyautomotive.com" .BCC = "" .Subject = "NetConsole Hours" .Body = strbody .Send  'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing ActiveWindow.Close Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub This is the macro that is  kicked off , when a sum is greater than zero. It sends an email to the  appropriate people , with the  appropriate message . This was another copy and paste, then change certain items.
Excel Macros Sub Email_NotEntered() ' ' Update Macro ' Macro recorded 4/16/2009 by durochs ' Application.Run "Anderson_Macro.xls!Diebold_email_start" Application.Run "Anderson_Macro.xls!Harris_email_start" Application.Run "Anderson_Macro.xls!Hulme_email_start" Application.Run "Anderson_Macro.xls!Irwin_email_start" Application.Run "Anderson_Macro.xls!Lee_email_start" Application.Run "Anderson_Macro.xls!Mahajan_email_start" Application.Run "Anderson_Macro.xls!Muqri_email_start" Application.Run "Anderson_Macro.xls!Stamey_email_start" Application.Run "Anderson_Macro.xls!Tucker_email_start" Application.Run "Anderson_Macro.xls!Email_NotEntered1" End Sub Since there are a lot of employees that need to be checked. I have set up this master email. It launches each macro, one after the other.
Excel Macros Sub Workbook_Open() Call Email End Sub Option Explicit Sub Email() Application.DisplayAlerts = False Application.ScreenUpdating = False On Error Resume Next  'turn error reporting off Workbooks.Open Filename:="I:\Payroll Histroy\Payroll\ADP User Guides & Paperwork\AN3 NetConsole Reports\Anderson_Macro.xls", Notify:=False If ActiveWorkbook.ReadOnly = True Then ActiveWorkbook.Close False Else Application.Run "Anderson_Macro.xls!Email_NotEntered" ActiveWindow.Close End If Application.DisplayAlerts = True Application.ScreenUpdating = True On Error GoTo 0 'turn error reporting back ThisWorkbook.Close End Sub In order to launch the master macro. I create a separate spreadsheet, that has a macro launch upon opening. I do this for two reasons: It allows me to create a scheduled task, that open this spreadsheet and then launches the series of macros. It is hard to break into a VBA code, when a query is running. So if I didn’t have a launching macro, it would be hard to update or add new macros.
Scheduled Tasks
Scheduled Tasks Scheduled Task allows me to set up my macros to run at night. Got to Start Settings Control Panel
Scheduled Tasks Select Scheduled Tasks
Scheduled Tasks Select  Add Scheduled Task Next
Scheduled Tasks Select  Browse
Scheduled Tasks Navigate to your spreadsheet, with the macro that launches upon opening
Scheduled Tasks Select how often you want the process to run. This one, I run weekly.
Scheduled Tasks Select Time Day of week
Scheduled Tasks Type in your desktop password and your done. You will have to update all of your tasks, whenever this password changes. Your computer needs to be on for these tasks to run.  I lock my computer, each night.
Scheduled Tasks Almost done. There is always some weird Microsoft hurdle to jump. Whenever you have Excel launch an email, a security warning pops up and you can’t easily code an automatic response. Download the software on this site and it always answer yes to those messages.
Making the digital certificate/signature
Making Digital Certificate One last problem When you open a spreadsheet that has a macro. You have to answer enable or disable macro. This can’t be coded either. Making a digital certificate solves this last problem. Select Start Programs
Making Digital Certificate Select Microsoft Office Microsoft Office Tools
Making Digital Certificate Select Digital Certificate for VBA Projects
Making Digital Certificate Type in a name Hit “OK”
Making Digital Certificate Your certificate is completed
Applying Certificate to VBA
Applying Certificate to VBA Open up your spreadsheet with the Macro. Hold down Alt F11
Applying Certificate to VBA Select Tools Digital Signatures
Applying Certificate to VBA Select Choose
Applying Certificate to VBA Select The certificate you made Hit OK
Applying Certificate to VBA Select Save Close
Applying Certificate to VBA Select Save Close
Always Trust Me
Always trust macro from this publisher Open spreadsheet(s) again. For a launch spreadsheet, do this at inception of the code and after testing everything (on the master macro). Click on check box for “Always trust macros from this publisher”. Select Enable Macros. When you open this again, there will be no more prompt.
User Instructions For the user (if there are any), they need to follow these instructions. Users will initially get a grayed out check box. They need to select Details
User Instructions Select View Certificate
User Instructions Select Install Certificate
User Instructions Select Next
User Instructions Select Next
User Instructions Select Finish
User Instructions Select Yes
User Instructions Select OK (on all open screens)
User Instructions Close out of grayed out screen and reopen spreadsheet. The user will now have the option to click on the check box.
End Result
End Result End result, is that an unwanted (non value added) job is eliminated. The possible for error, has now shrunk close to zero.

More Related Content

PPTX
Learn VBA Training & Advance Excel Courses in Delhi
DOC
Ms Excel
PDF
How to use microsoft excel
PDF
Microsoft Excel 2013 Basics course
PDF
Basic Functions - Excel 2013 Tutorial
PDF
Entering Data - Excel 2013 Tutorial
PPT
Excel 2007 Unit O
PDF
Top tips from the experts on how to learn Excel
Learn VBA Training & Advance Excel Courses in Delhi
Ms Excel
How to use microsoft excel
Microsoft Excel 2013 Basics course
Basic Functions - Excel 2013 Tutorial
Entering Data - Excel 2013 Tutorial
Excel 2007 Unit O
Top tips from the experts on how to learn Excel

What's hot (20)

PDF
Excel 2007-functions-formulas
PDF
AutoCorrect - Excel 2013 Tutorial
PDF
using excel 2013 as a power user
PPTX
PPTX
Microsoft Excel 101
PPTX
Excel® 2013
PPTX
Adv excel® 2013
PDF
ICDL Advanced Excel 2010 - Tutorial
PDF
Getting started with Microsoft Excel Macros
PPT
How To Automate Part 2
PPSX
DOC
Microsoft Excel Tutorial
PPTX
presentationMs excel
PPTX
Ms excel and it’s function
PDF
DashboardPlus-Excel based dashboard
PDF
Microsoft excel 2013 Quickstart
PDF
Worksheet Basics & Navigation - Excel 2013 Tutorial
PDF
Sample Excel 2013 Advanced Essentials
PPTX
Ms excel ppt
PDF
Introduction to Excel - Excel 2013 Tutorial
Excel 2007-functions-formulas
AutoCorrect - Excel 2013 Tutorial
using excel 2013 as a power user
Microsoft Excel 101
Excel® 2013
Adv excel® 2013
ICDL Advanced Excel 2010 - Tutorial
Getting started with Microsoft Excel Macros
How To Automate Part 2
Microsoft Excel Tutorial
presentationMs excel
Ms excel and it’s function
DashboardPlus-Excel based dashboard
Microsoft excel 2013 Quickstart
Worksheet Basics & Navigation - Excel 2013 Tutorial
Sample Excel 2013 Advanced Essentials
Ms excel ppt
Introduction to Excel - Excel 2013 Tutorial
Ad

Similar to Automation Of Reporting And Alerting (20)

PPT
How To Automate Part 3
PDF
Pivot tableinfo
PDF
Pivot tableinfo
PPT
How To Automate Part 1
PPTX
Intermediate Excel
PPT
Uses & applications of microsoft excel in vph research
PPTX
Advanced Excel Demo
PDF
Learn Basic Excel options within 15 minutes
PPTX
MS Excel and Visual Basic Applications.pptx
DOCX
Uses of excel
PDF
Pivot-Table-Handout1-projectcubicle lecture notes
PDF
Sage Intelligence 40 Microsoft Excel Tips and Tricks
PDF
Ms excel training
PPTX
Excel data analysis Advanced Microsoft Access 2010 Training on MS
PPT
Office excel tips and tricks 201101
DOCX
PDF
Create a PivotTable to analyze worksheet data.pdf
PDF
Excel tips&tricks
PPTX
Ms excel 2016 Advance Learning
PPTX
Computer class of agriculture production 3.pptx
How To Automate Part 3
Pivot tableinfo
Pivot tableinfo
How To Automate Part 1
Intermediate Excel
Uses & applications of microsoft excel in vph research
Advanced Excel Demo
Learn Basic Excel options within 15 minutes
MS Excel and Visual Basic Applications.pptx
Uses of excel
Pivot-Table-Handout1-projectcubicle lecture notes
Sage Intelligence 40 Microsoft Excel Tips and Tricks
Ms excel training
Excel data analysis Advanced Microsoft Access 2010 Training on MS
Office excel tips and tricks 201101
Create a PivotTable to analyze worksheet data.pdf
Excel tips&tricks
Ms excel 2016 Advance Learning
Computer class of agriculture production 3.pptx
Ad

Automation Of Reporting And Alerting

  • 1. Automation of Reporting and Alerting
  • 2.  
  • 3.  
  • 4. Microcosm The following presentation is an illustration of most of my automation techniques in one project. It is a microcosm of an automated set of systems I set up to; Illustrate and share data (in a secured location) Create audits (proactive and reactive) Trigger events (send emails)
  • 5. Techniques Secured folders Utilization of folder security instead of Excel passwords ODBC Connections Creating real time links to the database tables of applications. Access queries Bringing data (tables) for one or many applications together. Calculations being performed. Excel Pivot tables Illustrating data on a user friendly interface. Excel Macros Automation of the updating of spreadsheets Automation of emails sent to the right people. Scheduled tasks Starting the macros, at night.
  • 6. The project The project was to automate notifying employees (only certain exempt emps) to submit timesheets. An HR rep was doing this in the past (for her location) and she wanted a program that did this, without her having doing anything. The task was to set up pivot tables that illustrated 2 problems and with a summary and detail tab for each (4 tabs total). Pay periods that had no submitted hours. Pay periods that had hours, but hade never been submitted. Notifications were to be emailed automatically, every Tuesday morning.
  • 10. Groundwork The groundwork for this project had already been laid by existing projects. The goal was just to copy existing molds and create new processes.
  • 12. Folder security In a shared location create a folder. Have your IT department create a security group on the folder. This replacing have an Excel password (and is more secure)
  • 13. Folder security The folder I used, already had security and a variety of confidential excel spreadsheets
  • 15. Access Engine Access is going to be the powerhouse behind the process. It will access the tables (ODBC) and manipulate the data (queries), so they can be illustrated in Excel (pivot tables)
  • 17. ODBC connection ODBC connections are read only links to your applications tables. Once your source is updated, your ODBCs will be. Some applications, the ODBCs, are created upon installation. Others you will need your IT team to create for you. These connections are similar to what a SQL programmer might work with (but read only).
  • 18. ODBC connection 1 st thing to do is access the data (tables) via an ODBC connection. I had already established these real-time links and researched what data was in what table and what their common denominators were. These tables were from our salaried timekeeping system (NetConsole)
  • 19. ODBC connection Go to File Get External Data Link Tables If you select Import, it creates a static table, which is not automatically updated.
  • 20. ODBC connection Change “Files of type:” to ODBC databases()
  • 21. ODBC connection Select the Machine Data Source tab Select your database
  • 22. ODBC connection A list of the tables will appear. Select the one you want. This might involve a lot of trial and error. I usually select all and find out what each one contains.
  • 23. ODBC connection Here is one of the opened tables for my timekeeping system. Most tables have “IDs” that correspond with other tables. You will need to know what these mean, when you create queries. Most developers create relationships at the table level, but I prefer to do that at the query level (next set of slides).
  • 25. Access Queries The way I create queries, is by selecting; Create query in Design view
  • 26. Access Queries Select the tables of queries that you want to bring together
  • 27. Access Queries I had already created a base timesheet query, for other projects. So I could copy that base one and use that.
  • 28. Access Queries Once copied, select paste and name the new query
  • 29. Access Queries All of these tables get linked together by their “IDs” or a common denominator. In the end, they become one unified set of data. There is a lot of trail and error in this process and validation to know values.
  • 30. Access Queries Double click on the headers you want on you query.
  • 31. Access Queries Add criteria to narrow the range of the query.
  • 32. Access Queries Add formulas to perform your math. In this case I needed to change blanks caused by linking table and add create a total hours column. I used an IIF(IsNull) formula. It converts blank spaces to zeros, so that math can be performed.
  • 33. Access Queries One of the tasks of the project was to find who hadn’t entered hours for a pay period. This isn’t tracked in our attendance system. This query assigned a period to every one. Example: John Doe has a row for every pay period, in all of the years for our time keeping system.
  • 34. Access Queries By linking a query that has all of the timekeeping data, with one that assigns pay period regardless if worked. We now have a query, that tells us, you didn’t enter time
  • 35. Access Queries Next is giving a value to hours entered and hours missing (per payperiod). We can track that on a pivot table and run macros off that data.
  • 37. Excel Pivot Tables Next is creating a pivot table that has sums of the pay periods missing, so an email can get generated.
  • 38. Excel Pivot Tables To create a Pivot table Got to Data PivotTable and PivotChart Report
  • 39. Excel Pivot Tables Select External data source Next
  • 40. Excel Pivot Tables Select Get Data
  • 41. Excel Pivot Tables Select MS Access Database
  • 42. Excel Pivot Tables Navigate to folder location Select database
  • 43. Excel Pivot Tables Select Table or query Arrow (to move all headers over) Next (next couple screens)
  • 44. Excel Pivot Tables Select Finish
  • 45. Excel Pivot Tables Select Next
  • 46. Excel Pivot Tables Select Layout
  • 47. Excel Pivot Tables Select Headers you displayed on the picot table Drag and drop Page area is a big filter Row and column area illustrate text and groups Data area does the math
  • 48. Excel Pivot Tables Select Finish
  • 49. Excel Pivot Tables A default view of your pivot will appear. I never use the default, so the next slides will show how to change it. At the same time a list of your header will appear. You can close these at any time.
  • 50. Excel Pivot Tables If you don’t already have the pivot table toolbar, this would be a good time to add it. Select View Toolbars PivotTable
  • 51. Excel Pivot Tables Select Format Report Scroll down and select Table1 You can experiment and choose which one you like better.
  • 52. Excel Pivot Tables Once you change the report type, the rows and columns can get mismatched. You can go back to the layout, by right click on the pivot and selecting wizard. Or, you can pick up the header and drag it, to where you want it.
  • 53. Excel Pivot Tables Most items are defaulted to give subtotals. Which could be what you and could be an eye sore. To turn off the sub totals Right click on the data for that column and select Field Settings
  • 54. Excel Pivot Tables Change Subtotals to None
  • 55. Excel Pivot Tables If you don’t space between lines. Click on Layout Deselect Insert blank line after each item.
  • 56. Excel Pivot Tables I only needed a couple people for this process, which I can filter on the name header. Select the pull down arrow. Select (Show All). This deselects everyone. Select the names you need for this process.
  • 57. Excel Pivot Tables This is the finished version for the summary. This tab will drive my macro. For the detailed tab, you don’t need to redo the pivot table process. You just need to create a copy of the tab. Right click on tab and select Move or Copy
  • 58. Excel Pivot Tables Click Create a copy and Ok
  • 59. Excel Pivot Tables Right click anywhere on the pivot. Select Field List
  • 60. Excel Pivot Tables Drag and drop Period next to Supervisor. There will be a gray line that acts as a guide.
  • 61. Excel Pivot Tables Drag and drop NonSub on the Page field. This allows you to select certain items. You can select Field settings and hide items (like the zero).
  • 62. Excel Pivot Tables I selected one, so it would only illustrate, names with out pay periods. Which was none in this case.
  • 63. Excel Pivot Tables This is the summary tab for employees that didn’t enter any hours for a pay period.
  • 64. Excel Pivot Tables This is the detail tab, which illustrates; The supervisor and their employees that have pay periods with missing hours. I added back in the subtotal for supervisor and name headers.
  • 66. Excel Macros I usually create a blank spreadsheet to house my macros. Hit ALT F11 to open the VBA screen.
  • 67. Excel Macros Create your code in a Module. Or you can use the recorder to create your macros. I do that for some of my stuff, but emailing requires writing the code.
  • 68. Excel Macros Sub Diebold_email_start() ' Application.DisplayAlerts = False Application.ScreenUpdating = False On Error Resume Next 'turn error reporting off Workbooks.Open Filename:="P:\Payroll\Anderson\Anderson_Billable.xls", Notify:=False If ActiveWorkbook.ReadOnly = True Then ActiveWorkbook.Close False Else Sheets("NotEntered_Master").Select Range("A4").Select ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh ActiveWorkbook.Save Range("C5").Select Dim x As Integer x = Range("C5") If x = 0 Then ActiveWindow.Close Else Application.Run "Anderson_Macro.xls!Diebold_email" End If End If Application.DisplayAlerts = True Application.ScreenUpdating = True On Error GoTo 0 'turn error reporting back End Sub Like in Access, I had macros that did what I wanted, I just needed to copy them and change some info (in the colored boxes). This macro; Opens the spreadsheet just shown . Refreshes the pivot table Checks to see if Diebold (C5 on the pivot table) has a sum greater than zero If it doesn’t it closes the spreadsheet If it does it launches another macro
  • 69. Excel Macros Sub Diebold_email() Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "" & vbNewLine & vbNewLine & _ "You have not entered hours in NetConsole, for a prior period(s), please enter and submit these hours ASAP." & vbNewLine & _ "" & vbNewLine & _ "" & vbNewLine & _ "" On Error Resume Next With OutMail .To = "Brian.Diebold@inergyautomotive.com" .CC = "Brenda.Dutton@inergyautomotive.com; Mohammad.Muqri@inergyautomotive.com" .BCC = "" .Subject = "NetConsole Hours" .Body = strbody .Send 'or use .Display End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing ActiveWindow.Close Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub This is the macro that is kicked off , when a sum is greater than zero. It sends an email to the appropriate people , with the appropriate message . This was another copy and paste, then change certain items.
  • 70. Excel Macros Sub Email_NotEntered() ' ' Update Macro ' Macro recorded 4/16/2009 by durochs ' Application.Run "Anderson_Macro.xls!Diebold_email_start" Application.Run "Anderson_Macro.xls!Harris_email_start" Application.Run "Anderson_Macro.xls!Hulme_email_start" Application.Run "Anderson_Macro.xls!Irwin_email_start" Application.Run "Anderson_Macro.xls!Lee_email_start" Application.Run "Anderson_Macro.xls!Mahajan_email_start" Application.Run "Anderson_Macro.xls!Muqri_email_start" Application.Run "Anderson_Macro.xls!Stamey_email_start" Application.Run "Anderson_Macro.xls!Tucker_email_start" Application.Run "Anderson_Macro.xls!Email_NotEntered1" End Sub Since there are a lot of employees that need to be checked. I have set up this master email. It launches each macro, one after the other.
  • 71. Excel Macros Sub Workbook_Open() Call Email End Sub Option Explicit Sub Email() Application.DisplayAlerts = False Application.ScreenUpdating = False On Error Resume Next 'turn error reporting off Workbooks.Open Filename:="I:\Payroll Histroy\Payroll\ADP User Guides & Paperwork\AN3 NetConsole Reports\Anderson_Macro.xls", Notify:=False If ActiveWorkbook.ReadOnly = True Then ActiveWorkbook.Close False Else Application.Run "Anderson_Macro.xls!Email_NotEntered" ActiveWindow.Close End If Application.DisplayAlerts = True Application.ScreenUpdating = True On Error GoTo 0 'turn error reporting back ThisWorkbook.Close End Sub In order to launch the master macro. I create a separate spreadsheet, that has a macro launch upon opening. I do this for two reasons: It allows me to create a scheduled task, that open this spreadsheet and then launches the series of macros. It is hard to break into a VBA code, when a query is running. So if I didn’t have a launching macro, it would be hard to update or add new macros.
  • 73. Scheduled Tasks Scheduled Task allows me to set up my macros to run at night. Got to Start Settings Control Panel
  • 74. Scheduled Tasks Select Scheduled Tasks
  • 75. Scheduled Tasks Select Add Scheduled Task Next
  • 77. Scheduled Tasks Navigate to your spreadsheet, with the macro that launches upon opening
  • 78. Scheduled Tasks Select how often you want the process to run. This one, I run weekly.
  • 79. Scheduled Tasks Select Time Day of week
  • 80. Scheduled Tasks Type in your desktop password and your done. You will have to update all of your tasks, whenever this password changes. Your computer needs to be on for these tasks to run. I lock my computer, each night.
  • 81. Scheduled Tasks Almost done. There is always some weird Microsoft hurdle to jump. Whenever you have Excel launch an email, a security warning pops up and you can’t easily code an automatic response. Download the software on this site and it always answer yes to those messages.
  • 82. Making the digital certificate/signature
  • 83. Making Digital Certificate One last problem When you open a spreadsheet that has a macro. You have to answer enable or disable macro. This can’t be coded either. Making a digital certificate solves this last problem. Select Start Programs
  • 84. Making Digital Certificate Select Microsoft Office Microsoft Office Tools
  • 85. Making Digital Certificate Select Digital Certificate for VBA Projects
  • 86. Making Digital Certificate Type in a name Hit “OK”
  • 87. Making Digital Certificate Your certificate is completed
  • 89. Applying Certificate to VBA Open up your spreadsheet with the Macro. Hold down Alt F11
  • 90. Applying Certificate to VBA Select Tools Digital Signatures
  • 91. Applying Certificate to VBA Select Choose
  • 92. Applying Certificate to VBA Select The certificate you made Hit OK
  • 93. Applying Certificate to VBA Select Save Close
  • 94. Applying Certificate to VBA Select Save Close
  • 96. Always trust macro from this publisher Open spreadsheet(s) again. For a launch spreadsheet, do this at inception of the code and after testing everything (on the master macro). Click on check box for “Always trust macros from this publisher”. Select Enable Macros. When you open this again, there will be no more prompt.
  • 97. User Instructions For the user (if there are any), they need to follow these instructions. Users will initially get a grayed out check box. They need to select Details
  • 98. User Instructions Select View Certificate
  • 99. User Instructions Select Install Certificate
  • 104. User Instructions Select OK (on all open screens)
  • 105. User Instructions Close out of grayed out screen and reopen spreadsheet. The user will now have the option to click on the check box.
  • 107. End Result End result, is that an unwanted (non value added) job is eliminated. The possible for error, has now shrunk close to zero.