Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 4th, 2006, 10:04 AM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default Auto_Open in Excel Template

Hi All

Auto_Open works well with Excel Workbooks (*.xls). However, when this is applied to Excel templates, it does not get fired when the template is added as an add-in. Is there any other event that gets fired when the template is added.


C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Old January 4th, 2006, 10:27 AM
Friend of Wrox
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts

I have just tested the following three types of events...

In all 3 scenarios I have the following code in the workbook object.

Private Sub Workbook_Open()
    MsgBox ("Boo")
End Sub

Scenario 1
save the workbook (xls), close it and re-open it. You may be asked to enable the macro. do so and you will get a message box with Boo appear on screen.

Scenario 2
save the workbook as a template (xlt)., close it and goto file new then select the template from the shown items. You may be asked to enable the macro. do so and you will get a message box with Boo appear on screen.

Scenario 3
Save as xla Xl Add-in. Place it somewhere convenient e.g. my docs. close the file. open ablank workbook and goto tools add-ins - [Browse] to locate the xls file. Click ok to accept and you will see the msgbox appear.

Which of these you want I dont know. but I suggest the third as it sounds closest to the example you gave.



Old January 4th, 2006, 10:37 AM
Authorized User
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts

the Workbook event you're looking for is the AddinInstall event - it gets called when the workbook is installed as an addin

in the VB ide, double-click the special "ThisWorkbook" class of your project, and then select the built-in Workbook object from the list in the top-left combo box. In the top-right drop-down you'll see listed all the events that you can capture for the Workbook object

similarly, you may want to think about moving away from the Auto_Open macro procedure and using the Workbook's "Open" event instead

check the on-line help, or search the web - there are plenty of examples there

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to multiple Excel files using template ecapox Access VBA 0 February 5th, 2008 10:38 AM
Access data to Excel Template Hamerw Access VBA 1 November 22nd, 2006 12:38 AM
calling one template in other template VijayKumar XSLT 3 September 15th, 2005 11:12 AM
How to export SQL RS data to Excel template johnilett BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 August 4th, 2005 03:39 AM
Excel in win 2000 to excel winxp (excel 2002) Max Excel VBA 3 August 28th, 2003 04:44 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.