Article ID: 167909
Article Last Modified on 8/17/2005
' This subroutine copies the worksheets to use as the interface
' for the application into a new workbook each time that the
' add-in is opened.
Sub Auto_Open()
Dim NewBook As Workbook
Dim Ctr As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
' Create a new workbook.
Set NewBook = Workbooks.Add
' Copy the two worksheets into the new workbook.
ThisWorkbook.Sheets(Array("AddinSheet1", "AddinSheet2")).Copy _
before:=NewBook.Sheets(1)
' Delete all of the other sheets in the new workbook. The
' initial value of the counter is 1 greater than the number of
' worksheets that you want to copy into the new workbook.
For Ctr = 3 To NewBook.Sheets.Count
NewBook.Sheets(3).Delete
Next
End Sub
' This sample demonstrates that any buttons that you place on the
' interface worksheets are still functional when the worksheets are
' copied into a new workbook.
Sub Test()
MsgBox "This is a test"
End Sub
add-ins, creating in Visual Basic
Additional query words: XL97 secure securing protect XL
Keywords: kbhowto kbmacro kbprogramming kbui KB167909