Insert Text into field depending on dropdownlistbox 
Author Message
 Insert Text into field depending on dropdownlistbox

Hi all,
I'm new in VBA but try to manage the following situation.
Have a dropdown with 3 items (A,B,C)
Dependig what I'm selecting in the dropdown I want to fill in some text on a
defined "field"
Questions:
1) What kind of "field" do i have to palce in my form textmark ?
2) How to put in the text into this field ? tried as follows:

    if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
        Selection.GoTo What:=wdGoToBookmark, Name:="MyTextField"
        Selection.Find.ClearFormatting
        Selection.TypeText Text:="selection A"
  end if

Code does not work because document is protected
TIA

Dan



Sat, 30 Aug 2003 23:08:58 GMT  
 Insert Text into field depending on dropdownlistbox
Hi Dan,

Try something like:

if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
    thisdocument.BookMarks("BmkOptionA").Range.Text = "Selection A"
elseif thisdocument.formfields("MyDropDown").DropDown.Value = 2 then
    thisdocument.BookMarks("BmkOptionB").Range.Text = "Selection B"
End If

If still not working, repost.

Krgrds,
Perry



Quote:
> Hi all,
> I'm new in vba but try to manage the following situation.
> Have a dropdown with 3 items (A,B,C)
> Dependig what I'm selecting in the dropdown I want to fill in some text on
a
> defined "field"
> Questions:
> 1) What kind of "field" do i have to palce in my form textmark ?
> 2) How to put in the text into this field ? tried as follows:

>     if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
>         Selection.GoTo What:=wdGoToBookmark, Name:="MyTextField"
>         Selection.Find.ClearFormatting
>         Selection.TypeText Text:="selection A"
>   end if

> Code does not work because document is protected
> TIA

> Dan



Sun, 31 Aug 2003 10:27:18 GMT  
 Insert Text into field depending on dropdownlistbox
Perry,
Do make the dropdown showing up I need to protect the document.
If document is protected, I can't assign text to a bookmark field.
(Runtime error 5148)
TIA
Dan
Quote:

> Hi Dan,

> Try something like:

> if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
>     thisdocument.BookMarks("BmkOptionA").Range.Text = "Selection A"
> elseif thisdocument.formfields("MyDropDown").DropDown.Value = 2 then
>     thisdocument.BookMarks("BmkOptionB").Range.Text = "Selection B"
> End If

> If still not working, repost.

> Krgrds,
> Perry



> > Hi all,
> > I'm new in vba but try to manage the following situation.
> > Have a dropdown with 3 items (A,B,C)
> > Dependig what I'm selecting in the dropdown I want to fill in some text on
> a
> > defined "field"
> > Questions:
> > 1) What kind of "field" do i have to palce in my form textmark ?
> > 2) How to put in the text into this field ? tried as follows:

> >     if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
> >         Selection.GoTo What:=wdGoToBookmark, Name:="MyTextField"
> >         Selection.Find.ClearFormatting
> >         Selection.TypeText Text:="selection A"
> >   end if

> > Code does not work because document is protected
> > TIA

> > Dan



Sun, 31 Aug 2003 17:43:50 GMT  
 Insert Text into field depending on dropdownlistbox
Hi Dan,

insert a cross reference to the text of the bookmark "MyDropDown" and run a
macro on exit from that formfield that contains the code
ActiveDocument.Fields.Update to update the cross reference with the value
selected.

Please post any follow-up or new questions to the Newsgroups so that others
may benefit therefrom or contribute thereto.

Hope this helps,
Doug Robbins - Word MVP

Quote:

> Hi all,
> I'm new in vba but try to manage the following situation.
> Have a dropdown with 3 items (A,B,C)
> Dependig what I'm selecting in the dropdown I want to fill in some text on
a
> defined "field"
> Questions:
> 1) What kind of "field" do i have to palce in my form textmark ?
> 2) How to put in the text into this field ? tried as follows:

>     if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
>         Selection.GoTo What:=wdGoToBookmark, Name:="MyTextField"
>         Selection.Find.ClearFormatting
>         Selection.TypeText Text:="selection A"
>   end if

> Code does not work because document is protected
> TIA

> Dan



Sun, 31 Aug 2003 19:39:04 GMT  
 Insert Text into field depending on dropdownlistbox
I believe you can just check the "calculate on exit" property for the
formfield and it will refresh any REF fields.
--
Charles Kenyon

Word New User FAQ & Web Directory:
http://www.addbalance.com/word

Legal Users' Guide to Microsoft Word (supplemented)
http://www.addbalance.com/usersguide
 --------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Quote:
> Hi Dan,

> insert a cross reference to the text of the bookmark "MyDropDown" and run
a
> macro on exit from that formfield that contains the code
> ActiveDocument.Fields.Update to update the cross reference with the value
> selected.

> Please post any follow-up or new questions to the Newsgroups so that
others
> may benefit therefrom or contribute thereto.

> Hope this helps,
> Doug Robbins - Word MVP



Quote:
> > Hi all,
> > I'm new in vba but try to manage the following situation.
> > Have a dropdown with 3 items (A,B,C)
> > Dependig what I'm selecting in the dropdown I want to fill in some text
on
> a
> > defined "field"
> > Questions:
> > 1) What kind of "field" do i have to palce in my form textmark ?
> > 2) How to put in the text into this field ? tried as follows:

> >     if thisdocument.formfields("MyDropDown").DropDown.Value = 1 then
> >         Selection.GoTo What:=wdGoToBookmark, Name:="MyTextField"
> >         Selection.Find.ClearFormatting
> >         Selection.TypeText Text:="selection A"
> >   end if

> > Code does not work because document is protected
> > TIA

> > Dan



Mon, 01 Sep 2003 15:01:06 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Displaying text/input field depending on checkbox value

2. Insert Autotext - returned range depends on formatting?

3. Insert statement problem - text fields with apostrophes

4. inserting text to specific location into memo field

5. Generic insertion combo box (was :Insert text at Insertion point of a field)

6. Insert text at Insertion point of a field

7. inserting fields into text in WordPad

8. VBA - Format problem inserting high numeric value into text field in excel

9. Insert text toTO field

10. Insert text in BCC field

11. Pulling text from DocProperty fields in Word and inserting into textboxes

12. Inserting long text string into form fields

 

 
Powered by phpBB® Forum Software