PDA

View Full Version : MsgBox only when you first open the workbook?



jazzygeoff
10-16-2005, 04:25 AM
Hi Guys
Im new to Vba:hi: , so go easy with me!, Right I've been thrown in at the deep end by my work and I really need some help finishing of my print calculator.

I need a message box to apear the first time you open a workbook, and then for it never to appear again.

Many thanks in advance

Bob Phillips
10-16-2005, 04:29 AM
Hi Guys
Im new to Vba:hi: , so go easy with me!, Right I've been thrown in at the deep end by my work and I really need some help finishing of my print calculator.

I need a message box to apear the first time you open a workbook, and then for it never to appear again.

Many thanks in advance

Private Sub Workbook_Open()
On Error Resume Next
If Not Evaluate(ThisWorkbook.Names("___FirstTime").RefersTo) Then
MsgBox "This is the first time"
ThisWorkbook.Names.Add Name:="___FirstTime", RefersTo:="=TRUE"
ThisWorkbook.Names("___FirstTime").Visible = False
End If
End Sub

This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code

jazzygeoff
10-16-2005, 04:37 AM
Hi Thanks for this

Unfortunatly this doesnt work on mine because my calc doesnt allow the user to save when closing, therefore message comes up every time?

johnske
10-16-2005, 06:37 AM
Hi Geoff,

Try this alternative http://www.vbaexpress.com/kb/getarticle.php?kb_id=510

Regards,
John :)

Bob Phillips
10-16-2005, 11:02 AM
Hi Thanks for this

Unfortunatly this doesnt work on mine because my calc doesnt allow the user to save when closing, therefore message comes up every time?

That;s fine, just chuck in a save yourself in that code. You can continue to stop them saving on close.