A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

DocProps - driving me crazy!



 
 
Thread Tools Display Modes
  #1  
Old September 29th 07, 01:46 PM posted to microsoft.public.word.vba.general,microsoft.public.word.docmanagement
Summer
external usenet poster
 
Posts: 333
Default DocProps - driving me crazy!

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?

Ads
  #2  
Old September 29th 07, 03:12 PM posted to microsoft.public.word.vba.general,microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default DocProps - driving me crazy!

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
Word MVP web site http://word.mvps.org




"Summer" wrote in message ...
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?

  #3  
Old September 29th 07, 04:32 PM posted to microsoft.public.word.vba.general,microsoft.public.word.docmanagement
Klaus Linke
external usenet poster
 
Posts: 413
Default DocProps - driving me crazy!

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


  #4  
Old September 30th 07, 03:01 AM posted to microsoft.public.word.vba.general,microsoft.public.word.docmanagement
Summer
external usenet poster
 
Posts: 333
Default DocProps - driving me crazy!

I'm going to try this now.. thank you...
"Graham Mayor" wrote in message ...
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
Word MVP web site http://word.mvps.org




"Summer" wrote in message ...
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?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I CAN'T GET RID OF THIS LINE and IT'S DRIVING ME CRAZY! Ken Newberger Microsoft Word Help 8 September 24th 09 10:21 PM
Section break issue. Please help. It's driving me crazy. sectionbreakvictim Microsoft Word Help 12 September 28th 07 04:56 PM
Printing from word, it's driving me crazy cat lover Microsoft Word Help 1 July 17th 07 07:25 AM
Closing windows...driving me CRAZY! frustrated Microsoft Word Help 1 December 1st 06 05:05 PM
Word is driving me crazy! kathiemt Microsoft Word Help 4 April 5th 06 05:37 AM


All times are GMT +1. The time now is 11:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright ©2004-2020 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.