Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Open Event code via VBA
Hi all
I wish to write a routine that adds the following code to apprimately 300 files "Private Sub Workbook_Open() Dim YearsService As Single YearsService = Now() - Range("Start_Date") MsgBox Range("First_Name") & " " & Range("Surname") & " has a service record of " & _ Int(YearsService / 365) & " years and " & Int((YearsService Mod 365) / 31) & " months" End Sub" At the moment there is no Open Event code in the files I already have the routine to open the files one by one, make standard changes, (heading etc.) and save the files. That part works fine. However, now the client wants me to add an Open Event such as the above code. I had a look at John Walkenbach's book on adding code to a Module or adding a button but can't find a way of inserting the above into ThisWorkBook. Thanks, Peter Bircher Kwazulu-Natal, SA |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Which 'event' to run pivot chart formatting code on file open? | Charts and Charting in Excel | |||
What code do I use to attach event handler that will open my user. | Excel Worksheet Functions | |||
Inserting a worksheet into an open workbook via VBA code | Excel Programming | |||
Insert VBA code with a macro in a .xls file by workbook open event | Excel Programming | |||
Open Event Code Bug | Excel Programming |