Rich,
Just a stab. I didn't check to see what happens if the user is away
and doesnt' acknowledge the message box:
Sub Auto_Open()
Application.OnTime When:=Now + TimeValue("00:14:00"), Name:="MsgText"
End Sub
Sub MsgText()
MsgBox "This document will save and close in 60 seconds."
Application.OnTime When:=Now + TimeValue("00:01:00"),
Name:="myFileSave"
End Sub
Sub myFileSave()
ActiveDocument.Close wdSaveChanges
End Sub
> Hi, we have a control document which a number of users update on
> Fridays. The problem is sometimes people stay in the document
[quoted text clipped - 8 lines]
>
> Rich
Greg Maxey - 30 Mar 2007 13:35 GMT
Rich,
That won't work. The code stops when the message box is diplayed and
doesn't continue until the user clicks OK. Also the Sub Auto_Open
should be Sub AutoOpen
I toy around and see if I can come up with something that works.
> Rich,
>
[quoted text clipped - 27 lines]
>
> - Show quoted text -
Richhall - 30 Mar 2007 13:39 GMT
> Rich,
>
[quoted text clipped - 37 lines]
>
> - Show quoted text -
Cheers everyone! Even a message box without an OK, is fine. Just a
notice really.
Greg Maxey - 30 Mar 2007 13:49 GMT
Ok, you can use a UserForm timed to close as the warning message.
Put this code in the document project module:
Sub AutoOpen()
Application.OnTime When:=Now + TimeValue("00:14:00"), Name:="MsgText"
End Sub
Sub MsgText()
UserForm1.Show
Application.OnTime When:=Now + TimeValue("00:01:00"),
Name:="myFileSave"
End Sub
Sub myFileSave()
ActiveDocument.Close wdSaveChanges
End Sub
Add a userform with a caption and label to suit your needs and add
this code to the Userform:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
Private Sub UserForm_Activate()
DoEvents
'Set the display time in milliseconds
Sleep 1000
Unload Me
End Sub
> > Rich,
>
[quoted text clipped - 42 lines]
>
> - Show quoted text -
Richhall - 30 Mar 2007 14:29 GMT
Thanks, Sorry not a VB expert or anything. So I go to
Tools>Macros>VB Editor and under projects put the first bit in the
This Document panel and save, What do I need to do with the second
bit please?
Greg Maxey - 30 Mar 2007 15:07 GMT
Rich,
You will need to open the VB Editor (Alt+F11). If not already
displayed, display the Project Explorer and Properties windows using
the View menu.
Click on the Project(your document name) tree then use the Insert menu
to insert a module
Paste the first bit of code in the module
Use the Insert menu to insert a Userform.
Use the toolbox to place a lable on the userform and then use the
properties window to give the userform and the label a "Caption"
Right click the Userform and select view code. Paste the second bit
of code in.
> Thanks, Sorry not a VB expert or anything. So I go to
> Tools>Macros>VB Editor and under projects put the first bit in the
> This Document panel and save, What do I need to do with the second
> bit please?
Richhall - 30 Mar 2007 15:41 GMT
> Rich,
>
[quoted text clipped - 21 lines]
>
> - Show quoted text -
Cheers Greg