WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

fields macro template: run but doesn't work

 
   Home -> Office -> User Forms RSS
Next:  reversing names in a cell  
Author Message
yanez

External


Since: May 05, 2008
Posts: 1



(Msg. 1) Posted: Mon May 05, 2008 8:13 pm
Post subject: fields macro template: run but doesn't work
Archived from groups: microsoft>public>word>vba>userforms (more info?)

Hi!

I'm from Italy, so sorry for my English.
I've a very very simple form saved as template (.dot) with the following:

Public Sub MoF() ' male or female
If FormFields("Mr_or_Mrs").Result = "Mr" Then ' a dropdown field
msgbox "is_a_man" ' a testing code
FormFields("born").Result = "born_he"
Else:
FormFields("born").Result = "born_she"
End If
End Sub

(Italian has male e feminine for adjectives...ok..?.)

The macro is activated on the on exit event of the Mr_or_Mrs, i.e. once the
user has selected the proper item in the list.
The macro works on the protected template .dot file, but doesn't work on the
new protected documents opened from the template.
Testing the code with some msgbox it appears the macro runs but word unable
to get the value of the selected item in the dropdown (Mr or Mrs).
Protection allows fields filling in, while unprotecting the document disable
the dropdown field.

Many thanks in advance for your attention

yanez
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 5380



(Msg. 2) Posted: Tue May 06, 2008 3:07 am
Post subject: Re: fields macro template: run but doesn't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Are you sure that the macro is in the form template and not in your
normal.dot template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"yanez" <yanez.nspm RemoveThis @libero.it> wrote in message
news:LeITj.32577$o06.110@tornado.fastwebnet.it...
> Hi!
>
> I'm from Italy, so sorry for my English.
> I've a very very simple form saved as template (.dot) with the following:
>
> Public Sub MoF() ' male or female
> If FormFields("Mr_or_Mrs").Result = "Mr" Then ' a dropdown field
> msgbox "is_a_man" ' a testing code
> FormFields("born").Result = "born_he"
> Else:
> FormFields("born").Result = "born_she"
> End If
> End Sub
>
> (Italian has male e feminine for adjectives...ok..?.)
>
> The macro is activated on the on exit event of the Mr_or_Mrs, i.e. once
> the user has selected the proper item in the list.
> The macro works on the protected template .dot file, but doesn't work on
> the new protected documents opened from the template.
> Testing the code with some msgbox it appears the macro runs but word
> unable to get the value of the selected item in the dropdown (Mr or Mrs).
> Protection allows fields filling in, while unprotecting the document
> disable the dropdown field.
>
> Many thanks in advance for your attention
>
> yanez
>
>
>
Back to top
Login to vote
yanez

External


Since: May 06, 2008
Posts: 1



(Msg. 3) Posted: Tue May 06, 2008 10:06 am
Post subject: Re: fields macro template: run but doesn't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Doug Robbins - Word MVP" <dkr.TakeThisOut@REMOVECAPSmvps.org> wrote in message
news:OnYUHfurIHA.5872@TK2MSFTNGP04.phx.gbl...
> Are you sure that the macro is in the form template and not in your
> normal.dot template?
>
> Hope this helps.

> Doug Robbins - Word MVP

Thanks for your suggestion Doug, but yes, the macro code is in the template.
The fact is that if I save the template with a certain value, let's say Mrs,
selected, then no matter what I select on the new document: the macro still
continues thinking Mrs is the "result" for the field. Need an "update"
method ?
Maybe I'm going to change the approach: since the document is protected
there's no need to have it as a template, I can reset all fields each time
the .doc is opened isn't it?
Anyway I'd like to have suggestions for a better comprehension of the
matter...
Thank you

yanez
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 5380



(Msg. 4) Posted: Wed May 07, 2008 6:15 pm
Post subject: Re: fields macro template: run but doesn't work [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I just created a little form as a template with a dropdown and a text
formfield and with code similar to yours, except that I used

Public Sub MoF() ' male or female
With ActiveDocument
If FormFields("Mr_or_Mrs").Result = "Mr" Then ' a dropdown field
FormFields("born").Result = "born_he"
Else:
FormFields("born").Result = "born_she"
End If
End With
End Sub

and for a new document created from the template it works as expected. If
you want to send me your template, I will have a look at it for you.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"yanez" <yanez76.nspm RemoveThis @libero.it> wrote in message
news:KmUTj.33030$o06.19667@tornado.fastwebnet.it...
> "Doug Robbins - Word MVP" <dkr RemoveThis @REMOVECAPSmvps.org> wrote in message
> news:OnYUHfurIHA.5872@TK2MSFTNGP04.phx.gbl...
>> Are you sure that the macro is in the form template and not in your
>> normal.dot template?
>>
>> Hope this helps.
>
>> Doug Robbins - Word MVP
>
> Thanks for your suggestion Doug, but yes, the macro code is in the
> template.
> The fact is that if I save the template with a certain value, let's say
> Mrs, selected, then no matter what I select on the new document: the macro
> still continues thinking Mrs is the "result" for the field. Need an
> "update" method ?
> Maybe I'm going to change the approach: since the document is protected
> there's no need to have it as a template, I can reset all fields each time
> the .doc is opened isn't it?
> Anyway I'd like to have suggestions for a better comprehension of the
> matter...
> Thank you
>
> yanez
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> User Forms All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET