Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Kwanjangnim Kwanjangnim is offline
external usenet poster
 
Posts: 4
Default Drop down field formatting

Happy New Year everyone

i have a good knowledge of word, but know nothing about using macros. I have
created a form with dropdown fields with 2 or more choices, i would like to
attach a macro (conditional format) to each choice of selection (within the
DD field) that will change current font attributes according to the users
choice. can anyone help?

example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin


  #2   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default Drop down field formatting

Something like this should do. Set the macro to run on exit from the
dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using macros.
I have created a form with dropdown fields with 2 or more choices, i
would like to attach a macro (conditional format) to each choice of
selection (within the DD field) that will change current font
attributes according to the users choice. can anyone help?

example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin



  #3   Report Post  
Posted to microsoft.public.word.newusers
Beth Melton Beth Melton is offline
external usenet poster
 
Posts: 1,380
Default Drop down field formatting

Out of curiosity, why did you elect to use: Case Is="Not Selected" instead
of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case statement.
Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in uppercase
in the dropdown then it needs to be the same in the macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from the
dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using macros.
I have created a form with dropdown fields with 2 or more choices, i
would like to attach a macro (conditional format) to each choice of
selection (within the DD field) that will change current font
attributes according to the users choice. can anyone help?

example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin






  #4   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default Drop down field formatting

Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that to Case Is
=
but I still got the type error. Then I realised that dropdown.value was a
numerica value and changed that to Select Case oFF.Result and just didn't
take the time to change the case statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from the
dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin



  #5   Report Post  
Posted to microsoft.public.word.newusers
Beth Melton Beth Melton is offline
external usenet poster
 
Posts: 1,380
Default Drop down field formatting

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that to Case
Is =
but I still got the type error. Then I realised that dropdown.value was a
numerica value and changed that to Select Case oFF.Result and just didn't
take the time to change the case statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from the
dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin







  #6   Report Post  
Posted to microsoft.public.word.newusers
Kwanjangnim Kwanjangnim is offline
external usenet poster
 
Posts: 4
Default Drop down field formatting

thanks for the speedy response

Like i said, i know nothing about macros, i created the macro and attached
it to my dropdown field and the only thing that happened was on exit it would
ask me for the password to unprotect the document, if i cancelled, it
returned an error, if i entered the password, i was back to an unprotected
doc.

1. should this be happening? (i want the doc to remain protected)
2. do i need to insert the field name within the code?
3. also if i want to use different fonts, do i write the name of the font as
it appears within word (font selection) or spelling from fonts folder?

"Beth Melton" wrote:

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that to Case
Is =
but I still got the type error. Then I realised that dropdown.value was a
numerica value and changed that to Select Case oFF.Result and just didn't
take the time to change the case statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from the
dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin






  #7   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default Drop down field formatting

The document has to be unprotected to change the font and then reproteced.
The code is intended to do both. You will have to put your password where I
have used "test"

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect Password:="test"
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case "SELECTED"
oFF.Range.Font.Name = "Arial Bold"
Case "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

You do not need to put the field name in the code because the code works on
any selected dropdown field.

I used the font names from the font dropdown menu.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
thanks for the speedy response

Like i said, i know nothing about macros, i created the macro and
attached it to my dropdown field and the only thing that happened was
on exit it would ask me for the password to unprotect the document,
if i cancelled, it returned an error, if i entered the password, i
was back to an unprotected doc.

1. should this be happening? (i want the doc to remain protected)
2. do i need to insert the field name within the code?
3. also if i want to use different fonts, do i write the name of the
font as it appears within word (font selection) or spelling from
fonts folder?

"Beth Melton" wrote:

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that
to Case Is =
but I still got the type error. Then I realised that
dropdown.value was a numerica value and changed that to Select Case
oFF.Result and just didn't take the time to change the case
statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the
macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from
the dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin



  #8   Report Post  
Posted to microsoft.public.word.newusers
Kwanjangnim Kwanjangnim is offline
external usenet poster
 
Posts: 4
Default Drop down field formatting

Thanks for all your help

"Greg Maxey" wrote:

The document has to be unprotected to change the font and then reproteced.
The code is intended to do both. You will have to put your password where I
have used "test"

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect Password:="test"
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case "SELECTED"
oFF.Range.Font.Name = "Arial Bold"
Case "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

You do not need to put the field name in the code because the code works on
any selected dropdown field.

I used the font names from the font dropdown menu.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
thanks for the speedy response

Like i said, i know nothing about macros, i created the macro and
attached it to my dropdown field and the only thing that happened was
on exit it would ask me for the password to unprotect the document,
if i cancelled, it returned an error, if i entered the password, i
was back to an unprotected doc.

1. should this be happening? (i want the doc to remain protected)
2. do i need to insert the field name within the code?
3. also if i want to use different fonts, do i write the name of the
font as it appears within word (font selection) or spelling from
fonts folder?

"Beth Melton" wrote:

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that
to Case Is =
but I still got the type error. Then I realised that
dropdown.value was a numerica value and changed that to Select Case
oFF.Result and just didn't take the time to change the case
statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the
macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from
the dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin




  #9   Report Post  
Posted to microsoft.public.word.newusers
Kwanjangnim Kwanjangnim is offline
external usenet poster
 
Posts: 4
Default Drop down field formatting

hi again, the macro works very well thank-you, the only problem i have now is
that the document can easily be unprotected now, as a password is no longer
requested i assume this is because of the macro, can i protect the document
again once the field has been updated? thanks again

"Greg Maxey" wrote:

The document has to be unprotected to change the font and then reproteced.
The code is intended to do both. You will have to put your password where I
have used "test"

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect Password:="test"
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case "SELECTED"
oFF.Range.Font.Name = "Arial Bold"
Case "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

You do not need to put the field name in the code because the code works on
any selected dropdown field.

I used the font names from the font dropdown menu.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
thanks for the speedy response

Like i said, i know nothing about macros, i created the macro and
attached it to my dropdown field and the only thing that happened was
on exit it would ask me for the password to unprotect the document,
if i cancelled, it returned an error, if i entered the password, i
was back to an unprotected doc.

1. should this be happening? (i want the doc to remain protected)
2. do i need to insert the field name within the code?
3. also if i want to use different fonts, do i write the name of the
font as it appears within word (font selection) or spelling from
fonts folder?

"Beth Melton" wrote:

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that
to Case Is =
but I still got the type error. Then I realised that
dropdown.value was a numerica value and changed that to Select Case
oFF.Result and just didn't take the time to change the case
statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not Selected"
instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the
macro.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit from
the dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or more
choices, i would like to attach a macro (conditional format) to
each choice of selection (within the DD field) that will change
current font attributes according to the users choice. can anyone
help? example typical choices: DD field contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin




  #10   Report Post  
Posted to microsoft.public.word.newusers
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default Drop down field formatting

Reapply the password with the macro:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect Password:="test"
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case "SELECTED"
oFF.Range.Font.Name = "Arial Bold"
Case "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:="test"
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
hi again, the macro works very well thank-you, the only problem i
have now is that the document can easily be unprotected now, as a
password is no longer requested i assume this is because of the
macro, can i protect the document again once the field has been
updated? thanks again

"Greg Maxey" wrote:

The document has to be unprotected to change the font and then
reproteced. The code is intended to do both. You will have to put
your password where I have used "test"

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect Password:="test"
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case "SELECTED"
oFF.Range.Font.Name = "Arial Bold"
Case "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

You do not need to put the field name in the code because the code
works on any selected dropdown field.

I used the font names from the font dropdown menu.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
thanks for the speedy response

Like i said, i know nothing about macros, i created the macro and
attached it to my dropdown field and the only thing that happened
was on exit it would ask me for the password to unprotect the
document, if i cancelled, it returned an error, if i entered the
password, i was back to an unprotected doc.

1. should this be happening? (i want the doc to remain protected)
2. do i need to insert the field name within the code?
3. also if i want to use different fonts, do i write the name of the
font as it appears within word (font selection) or spelling from
fonts folder?

"Beth Melton" wrote:

Ah! That makes sense. :-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Beth,

It was just an oversight. I initially started out with

Select Case oFF.Dropdown.Value
Case "Not Selected"

and got a type error

Then I typed in Case Is and the editor automatically changed that
to Case Is =
but I still got the type error. Then I realised that
dropdown.value was a numerica value and changed that to Select
Case oFF.Result and just didn't take the time to change the case
statements.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Beth Melton wrote:
Out of curiosity, why did you elect to use: Case Is="Not
Selected" instead of Case "Not Selected"?

I've always seen Is be used for comparison operators in a Case
statement. Something like Case Is 50.

Also note that Select Case is case-sensitive so if SELECTED is in
uppercase in the dropdown then it needs to be the same in the
macro.

Please post all follow-up questions to the newsgroup. Requests
for assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/

"Greg Maxey" wrote in message
...
Something like this should do. Set the macro to run on exit
from the dropdown field:

Sub FormatResult()
Dim oFF As FormField
ActiveDocument.Unprotect
Set oFF = Selection.FormFields(1)
Select Case oFF.Result
Case Is = "Selected"
oFF.Range.Font.Name = "Arial Bold"
Case Is = "Not Selected"
oFF.Range.Font.Name = "Arial"
Case Else
'Do Nothing
End Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Kwanjangnim wrote:
Happy New Year everyone

i have a good knowledge of word, but know nothing about using
macros. I have created a form with dropdown fields with 2 or
more choices, i would like to attach a macro (conditional
format) to each choice of selection (within the DD field) that
will change current font attributes according to the users
choice. can anyone help? example typical choices: DD field
contains
1. Not selected (Arial)
2. SELECTED (Arial Black)

thanking you in advance for your help with this problem
colin



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting a Mail Merge Field Angela Mailmerge 2 May 24th 06 08:36 PM
Drop down form field motocrossed Tables 1 May 19th 06 10:00 AM
merge letter with drop down form field Sarah Mailmerge 2 January 24th 06 11:33 PM
Formatting merge fields: inserting a paragraph mark before a field Justin Cascio Mailmerge 1 August 30th 05 08:18 PM
form and form field formatting stacyo Microsoft Word Help 4 December 8th 04 04:52 PM


All times are GMT +1. The time now is 11:01 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"