Results 1 to 8 of 8

Thread: Dropdowns in Word Run Code First Time Selection Made but Not if Selection Changed

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Dropdowns in Word Run Code First Time Selection Made but Not if Selection Changed

    Can someone tell me why
    1. This code only changes the bookmark text the first time the selection is made but not if the user changes the selection thereafter?
    2. My document is set up as section protected for the first section only (to enable the dropdowns and checkboxes), but I have to directly tell it in the code to unprotect the doc in order for the macro to not error with the indication that the macro could not be run because the doc was protected?

    Code:
    Sub StatusM()
    
    ' If the value of the dropdown is "single" then the areas
    ' in the document that this should populate will also include
    ' the text " person"
    
        
        Dim vStatSelect As Integer
        Dim vStat As String
        
        vStatSelect = ActiveDocument.FormFields("Status").DropDown.Value
            
        Select Case vStatSelect
        
         Case 2
              vStat = "single person"
              
         Case 3
              vStat = "widow"
              
         Case 4
              vStat = "widower"
         
         End Select
         
         If ActiveDocument.ProtectionType <> wdNoProtection Then
        
        ActiveDocument.Unprotect
    
        End If
         
         
         
        Selection.GoTo What:=wdGoToBookmark, Name:="StatusP"
        Selection.Delete Unit:=wdCharacter, Count:=1
        Selection.InsertAfter vStat
        ActiveDocument.Bookmarks.Add Range:=Selection.Range, _
        Name:="StatusP"
        
        Selection.GoTo What:=wdGoToBookmark, Name:="Status"
        
        ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
         
        
    End Sub
    Last edited by silvrwood; Jun 6th, 2005 at 12:43 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width