Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Dorpdownlist as result of a value of a bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Evert - 12 Sep 2006 17:29 GMT
Hi all,

I am totaly new at this scripting and searched many of your already problems
but could not find a solution for my question so here it is....

In my form (Word 2003) I have a bookmark with a certain value (which is
determined by a dropdown box choosen value). This bookmark has a value TEL04A
or TEL04B. When the value is TEL04B then I would like to have a dropdown box
created and visible to the filler of the form but if it is TEL04A the box may
not be shown at all.

I tried this with the scripting below which does not give any error but also
does not give me a dropdown box.

So.... the question here is: what is wrong with the scripting or what am I
not doing correctly?

Thx

Evert

Sub optipointselekt()
If ActiveDocument.Bookmarks("tel04") = "TEL04B" Then
ActiveDocument.Bookmarks("stdadv").Select
 Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
   Selection.PreviousField.Select
   With Selection.FormFields(1)
       .Name = "soortoptipoint"
       .Enabled = True
       .OwnHelp = False
       .HelpText = ""
       .OwnStatus = False
       .StatusText = ""
   End With
   Selection.FormFields("soortoptipoint").DropDown.ListEntries.Clear
   Selection.FormFields("soortoptipoint").DropDown.ListEntries.Add Name:= _
       "Standard"
   Selection.FormFields("soortoptipoint").DropDown.ListEntries.Add Name:= _
       "Advanced"
End If
End Sub
Greg Maxey - 12 Sep 2006 18:19 GMT
Evert,

You will need a plain bookmark stdadv where you want the field to
appear.  As you can never tell what your users will do, it is a bit
more complicated than just having the result of the first dropdown add
a new field.  What if the user changes their mind and then changes it
again ;-)

Try this on exit from the dropdown named "tel04":

Sub optipointselekt()
Dim oFfld As FormFields
Dim oRng As Word.Range
Dim oDoc As Word.Document
Set oDoc = ActiveDocument
Set oFfld = oDoc.FormFields
Set oRng = oDoc.Bookmarks("stdadv").Range
oDoc.Unprotect
If oFfld("tel04").Result = "Tel04B" Then
 If Not ActiveDocument.Bookmarks.Exists("soortoptipoint") = True Then
   oFfld.Add Range:=oRng, Type:=wdFieldFormDropDown
   With oRng.FormFields(1)
     .Name = "soortoptipoint"
     .Enabled = True
     .OwnHelp = False
     .HelpText = ""
     .OwnStatus = False
     .StatusText = ""
   End With
   With oFfld("soortoptipoint").DropDown.ListEntries
     .Clear
     .Add "Standard"
     .Add "Advanced"
   End With
   oFfld("soortoptipoint").DropDown.Value = 1
 End If
Else
 If ActiveDocument.Bookmarks.Exists("soortoptipoint") = True Then
   oFfld("soortoptipoint").Delete
 End If
End If
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub

I didn't extensively test, but if the second formfield already exists
then you either want to ignore adding it again or delete it if
depending on subsequent user actions.

> Hi all,
>
[quoted text clipped - 37 lines]
> End If
> End Sub
Evert - 12 Sep 2006 18:55 GMT
I now get an error requested member of the collection does not exists. I will
send you an email about it. Hope you don't mind that.....

> Evert,
>
[quoted text clipped - 85 lines]
> > End If
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.