Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cheers and thanks to both of you.
Regards DavidC -----Original Message----- David, You need to setup the application event class, and initiate it in the workbook_open event. Below is the sort of code you need, in your case the newworkbook code is in the class module. But note vthe response from KeepItCool. '======================================== Insert a class module, rename it to 'clsAppEvents', with this code Option Explicit Public WithEvents App As Application Private Sub App_WorkbookOpen(ByVal Wb As Workbook) 'your code or a call to your macro End Sub '======================================== In ThisWorkbook code module, add this event code Dim AppClass As New clsAppEvents Private Sub Workbook_Open() Set AppClass.App = Application End Sub -- HTH RP "DavidC" wrote in message ... Short answer is no. I have never entered into that realm of coding yet. I guess from your question that I need to look at doing this first. Regards DavidC -----Original Message----- Have you set up an application class and defined App? -- HTH RP "DavidC" wrote in message ... Simple question, but I cannot find the answer. I want to run code ONLY when I open up a new workbook from the template workbook. Once the new workbook has opened it will set certain values which will then be stored when the workbook is saved as an xls file. When another workbook is opened using that same template then the code will run and fill in values again in the new workbook. However if the xls file is opened the values that were stored in the workbook remian and are not updated by the code. I have tried the following but it does not seem to work. (The message is a simple way of showing me that the code ran, and since the message does not come up then the code did not run.) Private Sub App_NewWorkbook(ByVal Wb As Workbook) response = MsgBox("Opening new workbook", vbOKOnly) Range("data1").Value = Date End Sub Thanks DavidC . . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook | Excel Worksheet Functions | |||
Select sheet tabs in workbook & save to separate workbook files | Excel Worksheet Functions | |||
Copy a range of cells in an unopened workbook and paste it to the current workbook | Excel Programming | |||
Open a password protected excel workbook from second workbook to fetch data using dynamic connection | Excel Programming | |||
What commands do you use to name a workbook, save a workbook,open a workbook | Excel Programming |