Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: How to coding this problem!

Geek News

How to coding this problem!
m2mhung 6/4/2007 6:36:01 AM
I created a form in MS Word and now I want to use it just by press "Show"
button.
The value of "text form fields" changed but it didn't show on the screen. I
must double click on "text form fields" which I want it show after that I
click "OK" from the form, its value change . How can I coding this? I
attached this file for you for your ref.
Thank you.
I can't find where I can upload my file? but my code is:

Private Sub cmdShow_Click()
'Set name
Set stName = ActiveDocument.FormFields("txtName").TextInput
stName.Default = txtName

'Set Address
Set stAddr = ActiveDocument.FormFields("txtAddr").TextInput
stAddr.Default = txtAddr

' Set country
Set stCountry = ActiveDocument.FormFields("txtCountry").TextInput
stCountry.Default = txtCountry
'Application.ScreenRefresh
End Sub
Re: How to coding this problem!
Susan <bogenexcel[ at ]aol.com> 6/4/2007 1:05:30 PM
you need 2 different routines:

1. this goes in a general module.
Private Sub cmdShow_Click()
load userform1 '<--- change to whatever your form name is
userform1.show
end sub

2. then, in the userform module, you need an initialization sub, that
sets those values......

private sub userform1_initialize()
[Quoted Text]
> 'Set name
> Set stName = ActiveDocument.FormFields("txtName").TextInput
> stName.Default = txtName
>
> 'Set Address
> Set stAddr = ActiveDocument.FormFields("txtAddr").TextInput
> stAddr.Default = txtAddr
>
> ' Set country
> Set stCountry = ActiveDocument.FormFields("txtCountry").TextInput
> stCountry.Default = txtCountry
> 'Application.ScreenRefresh
end sub

hope it helps!
susan


On Jun 4, 2:36 am, m2mhung <m2mh...[ at ]discussions.microsoft.com> wrote:
> I created a form in MS Word and now I want to use it just by press "Show"
> button.
> The value of "text form fields" changed but it didn't show on the screen. I
> must double click on "text form fields" which I want it show after that I
> click "OK" from the form, its value change . How can I coding this? I
> attached this file for you for your ref.
> Thank you.
> I can't find where I can upload my file? but my code is:
>
> Private Sub cmdShow_Click()
> 'Set name
> Set stName = ActiveDocument.FormFields("txtName").TextInput
> stName.Default = txtName
>
> 'Set Address
> Set stAddr = ActiveDocument.FormFields("txtAddr").TextInput
> stAddr.Default = txtAddr
>
> ' Set country
> Set stCountry = ActiveDocument.FormFields("txtCountry").TextInput
> stCountry.Default = txtCountry
> 'Application.ScreenRefresh
> End Sub


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net