Link to home
Start Free TrialLog in
Avatar of vannyx
vannyx

asked on

ms word 2007 Properties

can i create document templates that force a user to fill in the properties before they are allowed to save the file. Also how would i enforce a naming convention for the filename say xx.anything.xxx.xx.doc  with the xx being specific date like numbers or letters.
Avatar of hemaltrivedi
hemaltrivedi
Flag of India image

Hi Vannyx,

Here is a possible solution in Word 2007:

Firstly, you need to get down to some VBA coding and call a function on Document_Close() event which checks whether the required properties have been set or not. If not, then don't allow the user to close the document. The code may look like:

If Trim(ActiveDocument.BuiltInDocumentProperties("Title").Value) = "" Then
    MsgBox "Title not provided"
    ActiveDocument.Saved = False   'Dont save the document
    SendKeys "{ESC}"                     'Send the ESC key to avoid showing the save dialog box to users
else
    ActiveDocument.Saved = True       'Save the document
End If

You can also check for other properties like Author, Title, etc if those are mandatory for your case.

If you want to allow your users to enter values in the document itself and change the properties, you can insert those fields into the document. The following link shows how to add the document properties into the document:

http://vbadud.blogspot.com/2009/01/how-to-insert-document-properties-in.html

The second part of saving the file with a particular convention would require another line of code:

ActiveDocument.SaveAs (filenm)

where you can define filenm as something like:

filenm = "XYZ" & "." & cstr(month(now())) & "-" & cstr(year(now()))
or whatever you want

Note: Using SaveAs, a different copy gets created everytime. To avoid this, you can write some further code to check whether the file already exists. If yes, then simply use ActiveDocument.Saved=True. If you wish, you may also have the file created with required name, on the document open event.

Hope that helps

Hemal
Avatar of vannyx
vannyx

ASKER

So this would be coded into the template?  It doesnt need to be enforced onces the document is saved as, just on the first save we want the user to input certain properties and we dont want them to be able to save changes to the template without a password.
Well, you are right. This has to go into a template. But then the users need to use this template only. If they create documents from normal template then this approach won't work.

Hemal
Did the solution work? a feedback would be helpful.
Avatar of vannyx

ASKER

i havent tried it, its a little over my head and il need some time to try to figure it out.  Right now with my project load i dont have time.  I basically want to have something that is easy for the end user.  Because someone else is proposing a program called mfiles, which is a nice program but doesnt seem to scale very well and it also doesnt put any of the meta data in the actual document.  It also requires an agent and special interface to use it.
Avatar of vannyx

ASKER

couldnt find a solution that was easy to use.  Can i have this question refunded ?
Did you atleast try the solution provided? This will atleast give you a start. I agree its not foolproof but once the template is used, you will have the desired results. The only thing you need to take care is to establish a practice of having the users use the template.

Hemal
ASKER CERTIFIED SOLUTION
Avatar of vannyx
vannyx

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