Thread: New Workbook
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DavidC[_2_] DavidC[_2_] is offline
external usenet poster
 
Posts: 44
Default New Workbook

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