ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook Open Procedure in Custom Template File (https://www.excelbanter.com/excel-programming/407252-workbook-open-procedure-custom-template-file.html)

Hank

Workbook Open Procedure in Custom Template File
 
I have an Excel file containing raw data (e.g. "RawData.xls") that must be
automatically formatted according to a customized report template. In this
raw data file I have a custom toolbar button thats assigned a hyperlink to
my Excel report template (e.g. €œReportTemplate.xlt€). The Excel template has
a Workbook_Open() procedure that automatically formats the raw data file then
closes itself leaving the newly formatted raw data report open. Everything
gets formatted perfectly, however, after completing the formatting and
closing the report template file a Microsoft Office dialogue box pops up
asking me if I would like to open the file €œReportTemplate.xlt€. I dont
understand why its attempting to reopen my template again? Any insight and
suggestions would be appreciated.

Heres a snippet of the Open Workbook procedure contained in
€œReportTemplate.xlt€ :

Private Sub Workbook_Open()
' turn off warning messages
Application.DisplayAlerts = False
' Switch to raw data sheet
Workbooks("RawData.xls").Activate
Range("A1").Select

€¦. €˜ Format Raw data file code is omitted for simplicity sake €¦


€˜ Close €œReportTemplate.xlt€ without saving changes
Workbooks("ReportTemplate.xlt").Close SaveChanges:=False
End Sub


Note: Even if I reduce the Open Workbook procedure to the lines shown above,
I still receive the Microsoft Office dialogue box asking me if I would like
to open the template file again.



All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com