#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 201
Default once only pop up

Hi there,

I've created a message that comes up upon opening a worksheet template i've
created that reminds the user to resave this workbook first before using it
so as not to loose the template.

i've done this using the following code:

Private Sub Workbook_Open()
Dim MyBox As Object
Dim Duration As Long
Duration = 4 'Seconds
Msg = "Resave this workbook first"
Ttl = " Resave"
Set MyBox = CreateObject("WScript.Shell")
response = MyBox.PoPup(Msg, Duration, Ttl, vbOKCancel)
End Sub


The only problem is when i then open the resaved document. the message comes
up everytime (obviously). What can i add to my code so that it only comes up
the one time for that workbook but without loosing it so that it doesn't pop
up in the future when i open the workbook for a new weekending.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default once only pop up

On Dec 27, 7:52*pm, Phil wrote:
Hi there,

I've created a message that comes up upon opening a worksheet template i've
created that reminds the user to resave this workbook first before using it
so as not to loose the template.

i've done this using the following code:

Private Sub Workbook_Open()
Dim MyBox As Object
Dim Duration As Long
Duration = 4 'Seconds
Msg = "Resave this workbook first"
Ttl = " Resave"
* * Set MyBox = CreateObject("WScript.Shell")
* * response = MyBox.PoPup(Msg, Duration, Ttl, vbOKCancel)
End Sub

The only problem is when i then open the resaved document. the message comes
up everytime (obviously). What can i add to my code so that it only comes up
the one time for that workbook but without loosing it so that it doesn't pop
up in the future when i open the workbook for a new weekending.


You might consider using a cell somewhere in the workbook, that you
know will never be used, as a container to store some sort of boolean/
flag type value. then you could just insert a simple if statement
into your code to check for a positive value. If the flag is set,
then skip out of the routine, if it isn't set yet, run the routine and
set the flag. Hope that helps...
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 695
Default once only pop up

or define a name "Test" in refers to put this =0

then put this in ur code

If ActiveWorkbook.Names("Test") = "=0" Then
ActiveWorkbook.Names.Add "Test", 1
'ur msg
End If


"Mark" skrev:

On Dec 27, 7:52 pm, Phil wrote:
Hi there,

I've created a message that comes up upon opening a worksheet template i've
created that reminds the user to resave this workbook first before using it
so as not to loose the template.

i've done this using the following code:

Private Sub Workbook_Open()
Dim MyBox As Object
Dim Duration As Long
Duration = 4 'Seconds
Msg = "Resave this workbook first"
Ttl = " Resave"
Set MyBox = CreateObject("WScript.Shell")
response = MyBox.PoPup(Msg, Duration, Ttl, vbOKCancel)
End Sub

The only problem is when i then open the resaved document. the message comes
up everytime (obviously). What can i add to my code so that it only comes up
the one time for that workbook but without loosing it so that it doesn't pop
up in the future when i open the workbook for a new weekending.


You might consider using a cell somewhere in the workbook, that you
know will never be used, as a container to store some sort of boolean/
flag type value. then you could just insert a simple if statement
into your code to check for a positive value. If the flag is set,
then skip out of the routine, if it isn't set yet, run the routine and
set the flag. Hope that helps...
.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default once only pop up

A saved workbook will have a path.

An unsaved workbook will not.

Check for the path and Exit Sub if path is found.

If not, carry on with message.

Private Sub Workbook_Open()
Dim MyBox As Object
Dim Duration As Long

If ActiveWorkbook.Path < "" Then Exit Sub

Ttl = " Resave"
Set MyBox = CreateObject("WScript.Shell")
response = MyBox.PoPup(Msg, Duration, Ttl, vbOKCancel)
End Sub


On Sun, 27 Dec 2009 17:52:03 -0800, Phil
wrote:

Hi there,

I've created a message that comes up upon opening a worksheet template i've
created that reminds the user to resave this workbook first before using it
so as not to loose the template.

i've done this using the following code:

Private Sub Workbook_Open()
Dim MyBox As Object
Dim Duration As Long
Duration = 4 'Seconds
Msg = "Resave this workbook first"
Ttl = " Resave"
Set MyBox = CreateObject("WScript.Shell")
response = MyBox.PoPup(Msg, Duration, Ttl, vbOKCancel)
End Sub


The only problem is when i then open the resaved document. the message comes
up everytime (obviously). What can i add to my code so that it only comes up
the one time for that workbook but without loosing it so that it doesn't pop
up in the future when i open the workbook for a new weekending.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"