Altering the Doc properties from inside a document

  • Thread starter Thread starter Mumbly_Joe
  • Start date Start date
M

Mumbly_Joe

So my question might be a little convoluted but here goes nothing.

I'm trying to create a template that has some kind of textbox that changes
the document property (specifically "category") to what ever has been typed
in the box.

I'm not really certain where to begin
 
Ok, Maybe a better way to phrase this question is that I'm looking ot creat
some sort of textbox, field cell ect... that runs a macro when ever text is
typed in it (A ma cro that will in this case change a doc property)
 
If you add the following autonew macro to your document, it will prompt on
creating a new document and write what you enter in the box to the Category
document property then update any fields in the document. If you are using a
docproperty field elsewhere than in the main text area, you may need a more
robust update routine to catch it - see
http://www.gmayor.com/installing_macro.htm

Sub AutoNew()
Dim sCat As String
sCat = InputBox("Enter category", "Category")
ActiveDocument.BuiltInDocumentProperties("Category").Value = sCat
ActiveDocument.Fields.Update
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
The simple expedient of typing text into some form of field is not going to
be sufficient to trigger the macro. You could run it on exit from a
protected form field or a Word 2007 content control - even a table cell, but
you have to take some specific action to trigger the macro that is more than
simply typing.

If the macro I suggested earlier is unsuitable, then let us know the purpose
of the exercise. There may be a better solution.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Thanks, that's really helpful, but I have a bit of a follow up question to
ask now.

I'm putting together this template for some co-workers and the the feedback
I've gotten is that that they want an easy way to change it at a later time.
So let's say that it starts out as a "Blue" and then later down the line they
need to change to a "Red". Now let's pretend it's difficult to modify a doc
category manually, is there an easy way to make like a dutton on the doc that
runs the maco again?
 
Back
Top