I’m opening a workbook from Access, populating and formatting some cells and saving the workbook. I need to put some code in workbook sub so when user opens the spreadsheet code will be triggered. Below is the code that I use to create the workbook.


VB Code:
  1. Dim xlExcel As Excel.Application
  2. Dim xlWorkbook As Excel.Workbook
  3. Dim xlWorksheet As Excel.Worksheet
  4.  
  5. Set xlExcel = CreateObject("Excel.Application")
  6. Set xlWorkbook = xlExcel.Workbooks.Open(strFilePath)
  7.  
  8. 'do some formating
  9. 'need to change or put some code in Workbook_Open()
  10.  
  11.  
  12. xlWorkbook.Save
  13. xlWorkbook.Close
  14. xlExcel.Application.Quit
  15. Set xlWorkbook = Nothing
  16. Set xlExcel = Nothing
Please let me know if that is possible to modify the code in the Workbook_Open(). Thanks for your help.