Link to home
Start Free TrialLog in
Avatar of hivos
hivosFlag for India

asked on

to enable autoclose timers in word file

I would like to enable a a timer  say 1hr when a word file is opened for editing and it should automatically save and close with password protect the file and only the author should know the password.
Avatar of darbid73
darbid73
Flag of Germany image

There are a thousand questions and things that can happen here.

Here is your starting code for the actual timer you need to add your time value as you want.

Sub Document_Open() 
    Application.OnTime When:=Now + TimeValue("00:00:00"), Name:="CloseDoc" 
End Sub 
 
Sub CloseDoc() 
    Dim oSH As Shape 
    'Do you magic here 
    
End Sub 

Open in new window


Lets start with some questions (as I am sure I will not get them all)
What version of word?
What happens if the user blocks vba code when opening the document
Where should the doc be saved?
How should the password be set and when?
What happens if the user closes down the doc before the time is up?
sorry that code again - cleaned up properly.

Sub Document_Open() 
    Application.OnTime When:=Now + TimeValue("00:00:00"), Name:="CloseDoc" 
End Sub 
 
Sub CloseDoc() 
    
    'Do your magic here 
    
End Sub 

Open in new window

Avatar of hivos

ASKER

Thanks, but
I wanted with a password protection feature so that only owner of the file for the current vb macro could open the file again after it is saved and closed
<I wanted with a password protection feature so that only owner of the file for the current vb macro could open the file again after it is saved and closed>

Yes I know that.  but before I get out my crystal ball how about you let us know a little but more about how this should happen.

eg can the user choose a password? etc see my comments above.

If the save as with password is all you want to put into the routine CloaseDoc then here is the MSDN theory and example
Avatar of hivos

ASKER

Sorry, I didn't read your comments
This assignment is to create document with necessary code to have built in timer say 1 hr
for the interview candidate to work on the document,
I have enabled timer feature, with auto save and auto close and it is working fine.
and the document is stored/saved in default location (i.,e its original location he/she copies the
document first time)

You are right I didn't think about if he/she closes  the document before 1hr
a) any suggestion on it is welcome
b) I never thought about how to remove macro security restrictions on the file except I have
    stored the file as macro enabled file and requested the candidate to remove the macro security the
    feature or warning. - alternative suggestions are welcome
c) This password feature I though the interview candidate should not know so that he/she does
    not have second access to the file once the file is closed
    -suggestions on it is welcome

Last but not the least; any way we could trace how long the candidate was working on the document file (since we wanted to restrict the document to be accessed for 1hr maximum)

Regards
manju
ASKER CERTIFIED SOLUTION
Avatar of darbid73
darbid73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial