DocProps - driving me crazy!

S

Summer

Hi,

I’m blank! Is it possible to write a toggle macro to toggle through 4 options for a DOCPROPERTY where the value is m or f or p or n = Mr or Mrs or Mr & Mrs or Blank



I thought maybe I could set Gender = m OR f OR p OR n using a macro? I use male female plural neuter as my options – so I need a macro that can toggle also as well as a field nest that works:



This is simple with Male or Female but I am trying to expand on this:



{IF {DOCPROPERTY Gender \ * MERGEFORMAT } = male Mr Ms \* MERGEFORMAT }



I need to add Male or Female or Plural or Neuter



So far I have this field nesting:



{DOCPROPERTY “gender” \ MERGEFORMAT }

{IF { = AND({ IF {DOCPROPERTY “gender” } = “male” 1 0 }, { IF {DOCPROPERTY “gender” } = “neuter” 1 0 }) } = 1 “Mr” “Mr & Mrs” \ *MERGEFORMAT }

Any ideas anyone please?
 
G

Graham Mayor

I would probably do something along the lines of

Dim sGender As String
Start:
sGender = InputBox("Enter gender letter = m, f, p, n", "Gender")
If UCase(sGender) <> "M" And UCase(sGender) <> "F" _
And UCase(sGender) <> "P" And UCase(sGender) <> "N" Then
MsgBox "Enter correct letter!", vbCritical
GoTo Start:
End If
Select Case LCase(sGender)
Case Is = "m"
sGender = "Mr."
Case Is = "f"
sGender = "Ms."
Case Is = "p"
sGender = "Mr. & Mrs."
Case Is = "n"
sGender = "neuter"
Case Else
'Do nothing
End Select
ActiveDocument.CustomDocumentProperties("Gender").Value = sGender
ActiveDocument.Fields.Update

which will write the required string to the pre-existing DocProperty field Gender. You can then use the field {DocProperty Gender} in the document. The macro will update the field to show the correct result.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Hi,

I’m blank! Is it possible to write a toggle macro to toggle through 4 options for a DOCPROPERTY where the value is m or f or p or n = Mr or Mrs or Mr & Mrs or Blank



I thought maybe I could set Gender = m OR f OR p OR n using a macro? I use male female plural neuter as my options – so I need a macro that can toggle also as well as a field nest that works:



This is simple with Male or Female but I am trying to expand on this:



{IF {DOCPROPERTY Gender \ * MERGEFORMAT } = male Mr Ms \* MERGEFORMAT }



I need to add Male or Female or Plural or Neuter



So far I have this field nesting:



{DOCPROPERTY “gender” \ MERGEFORMAT }

{IF { = AND({ IF {DOCPROPERTY “gender” } = “male” 1 0 }, { IF {DOCPROPERTY “gender” } = “neuter” 1 0 }) } = 1 “Mr” “Mr & Mrs” \ *MERGEFORMAT }

Any ideas anyone please?
 
K

Klaus Linke

Hi Summer,

Instead of nesting fields and creating complicated constructs, maybe create
a bookmark "address" for how to address the person, and use something like
this to change the text of the bookmark:
{ IF { DOCPROPERTY "gender" } = "male" { Set address "Mr" } }
{ IF { DOCPROPERTY "gender" } = "female" { Set address "Mrs" } }
{ IF { DOCPROPERTY "gender" } = "neuter" { Set address "Mr & Mrs" } }

Regards,
Klaus
 
S

Summer

I'm going to try this now.. thank you...
I would probably do something along the lines of

Dim sGender As String
Start:
sGender = InputBox("Enter gender letter = m, f, p, n", "Gender")
If UCase(sGender) <> "M" And UCase(sGender) <> "F" _
And UCase(sGender) <> "P" And UCase(sGender) <> "N" Then
MsgBox "Enter correct letter!", vbCritical
GoTo Start:
End If
Select Case LCase(sGender)
Case Is = "m"
sGender = "Mr."
Case Is = "f"
sGender = "Ms."
Case Is = "p"
sGender = "Mr. & Mrs."
Case Is = "n"
sGender = "neuter"
Case Else
'Do nothing
End Select
ActiveDocument.CustomDocumentProperties("Gender").Value = sGender
ActiveDocument.Fields.Update

which will write the required string to the pre-existing DocProperty field Gender. You can then use the field {DocProperty Gender} in the document. The macro will update the field to show the correct result.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Hi,

I’m blank! Is it possible to write a toggle macro to toggle through 4 options for a DOCPROPERTY where the value is m or f or p or n = Mr or Mrs or Mr & Mrs or Blank



I thought maybe I could set Gender = m OR f OR p OR n using a macro? I use male female plural neuter as my options – so I need a macro that can toggle also as well as a field nest that works:



This is simple with Male or Female but I am trying to expand on this:



{IF {DOCPROPERTY Gender \ * MERGEFORMAT } = male Mr Ms \* MERGEFORMAT }



I need to add Male or Female or Plural or Neuter



So far I have this field nesting:



{DOCPROPERTY “gender” \ MERGEFORMAT }

{IF { = AND({ IF {DOCPROPERTY “gender” } = “male” 1 0 }, { IF {DOCPROPERTY “gender” } = “neuter” 1 0 }) } = 1 “Mr” “Mr & Mrs” \ *MERGEFORMAT }

Any ideas anyone please?
 

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

Similar Threads


Top