add delete custom fields in properties window disabled...why?

D

DG

1) I am following some tutorials on VBA specifically to learn the
DocVariable fields. It says I should go to the File/Properties/Custom
dialog box and add the field there first. I go there and can type the
name of the field, select the type and even type a value, but the ADD
DELETE buttons are always grayed out. They stay gray even after
populating the boxes. I tried a blank document, an old document,
etc....same thing...tried closing opening word again...same thing.
I am using Word 2003 on a public computer (I pay to access it), could
this be a security setting in the computer? I was told that the
computers are completely open and nothing is prohibited, so I doubt it
might be anything like that. Any ideas?

2) the reason I am looking into DocVariable is that I want to
programmatically insert different Autotext into the headers (different
one for each odd portrait, even portrait, odd landscape, even
landscape). I am now able to differentiate portrait/landscape sections,
insert different even odd autotext headers...I can now even get the
info I need from the user using an inputbox, but now I have to place
the info I get from the input box into a variable field in the autotext
entries. From what I read, DocVariable is the way to go....am I right?
Any other suggestions?

thanks.
 
J

Jay Freedman

1) I am following some tutorials on VBA specifically to learn the
DocVariable fields. It says I should go to the File/Properties/Custom
dialog box and add the field there first. I go there and can type the
name of the field, select the type and even type a value, but the ADD
DELETE buttons are always grayed out. They stay gray even after
populating the boxes. I tried a blank document, an old document,
etc....same thing...tried closing opening word again...same thing.
I am using Word 2003 on a public computer (I pay to access it), could
this be a security setting in the computer? I was told that the
computers are completely open and nothing is prohibited, so I doubt it
might be anything like that. Any ideas?

2) the reason I am looking into DocVariable is that I want to
programmatically insert different Autotext into the headers (different
one for each odd portrait, even portrait, odd landscape, even
landscape). I am now able to differentiate portrait/landscape sections,
insert different even odd autotext headers...I can now even get the
info I need from the user using an inputbox, but now I have to place
the info I get from the input box into a variable field in the autotext
entries. From what I read, DocVariable is the way to go....am I right?
Any other suggestions?

thanks.

Well...

First off, Word documents can contain two different kinds of things,
document *properties* and document *variables*. They aren't
interchangeable.

Custom document properties can be inserted in the File > Properties >
Custom tab. I have no idea why you can't get that to work, although
public computers can get screwed up in a million unimaginable ways.
The same properties can be created through VBA instead, using the
ActiveDocument.CustomDocumentProperties.Add method. To display the
value of a document property in the document (including its header),
insert a {DOCPROPERTY} field containing the property's name.

Document variables must be created by VBA code; there is no dialog for
them. To do this, you use the ActiveDocument.Variables.Add method. To
display them in the document, insert a {DOCVARIABLE} field containing
the variable's name.

[Hint: If you use the Add method to try to define a variable that
already exists, VBA throws an error. A better method is simply to
assign it a value, like ActiveDocument.Variables("foo").Value = "bar".
If the variable doesn't exist yet, this statement creates it; if it
does exist, the statement changes the value.]

I'm trying to understand what you're doing. Am I correct that your
AutoText entries contain both plain text and fields, and you want the
fields to display the user's input? In that case, yes, I think
document variables are appropriate. However, I think you should look
into userforms (see, for example,
http://www.word.mvps.org/FAQs/Userforms/CreateAUserForm.htm) instead
of individual input boxes. Once the userform has collected the user's
input, the code attached to the form can create the document
variables. There are advantages to this: the code can validate the
input (for example, to make sure the user hasn't left a required field
blank), and it's less annoying to fill out one form than to be
presented with a string of popups.
 
V

voip1234

Thanks Jay, that worked...with a but....
it works, but the only way I get to see the DocVariable
fields in the document is by first selecting Print Preview.
After that, the correct variable is displayed. I suppose this
updates the field. What would the VBA code be so that
the macro updates the fields before it finishes executing.
(the fields are in the headers...dont know if that makes a
difference)
thanks for your help!!!! very much appreciated!!!
 
J

Jay Freedman

Thanks Jay, that worked...with a but....
it works, but the only way I get to see the DocVariable
fields in the document is by first selecting Print Preview.
After that, the correct variable is displayed. I suppose this
updates the field. What would the VBA code be so that
the macro updates the fields before it finishes executing.
(the fields are in the headers...dont know if that makes a
difference)
thanks for your help!!!! very much appreciated!!!

That's a common problem. Among others, Peter Hewett has posted code to
update all the fields in the document. It's at
http://groups-beta.google.com/group/microsoft.public.word.vba.userforms/msg/12dad96cad309e29

You're correct that going to Print Preview updates the fields (but
only if the "Update fields" option is checked in Tools > Options >
Print).
 
V

voip1234

Thanks Jay, it worked perfectly.
Now on to making the userforms to some error checking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top