View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joseph N. Joseph N. is offline
external usenet poster
 
Posts: 5
Default VBA script on document open or close

I'm trying to put into Excel a procedure that I have put into Word
(through the assistance of Greg Maxey). There seems to be two issues:
making some procedure operate by default, and using the correct code.

For the first problem, I followed the online help and tried to put the
code in a workbook and then saved the workbook as
\\%userprofile%\application data\microsoft\templates\book.xlt . When
that did not work, I saved it as c:\program files\microsoft
office\office11\xlstart\book.xlt . That did not work either, so I
don't know if the process was incorrect or if the code--which is
verbatim the same as I used in Word--is incorrect (since I know next to
nothing about VBA), or something else is incorrect.

Here's the code I used:

Sub AutoOpen()
If ActiveDocument.BuiltInDocumentProperties("Title") = "" Then
With Dialogs(wdDialogFileSummaryInfo)
.Show
End With
End If
End Sub

Sub AutoClose()
If ActiveDocument.BuiltInDocumentProperties("Title") = "" Then
With Dialogs(wdDialogFileSummaryInfo)
.Show
End With
End If
End Sub

So... can anyone point me in the right direction on making Excel
always prompt for a Title if the Title properties field is blank? (And
the reason I need it on both open and close has to do with automatic
document creation generated sometimes by a different program.)

TIA