Thread: [Solved] Help with if then statements
View Single Post
 
Old 07-18-2015, 04:37 AM
brent chadwick brent chadwick is offline Windows 8 Office 2013
Advanced Beginner
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Here's the doc that has all of the text that the macro needs to produce. The years (1790-1940) are in a drop-down menu. The regular non-conditional form fields are the grey highlighted ones. There are 6 conditional form fields depending on the chosen year highlighted in yellow. There is one conditional drop-down menu (AorB).
What is done-
The year drop-down. All of the text and conditional text. All of the bookmarks for the conditional form fields.
What I need help on-
The conditional form fields and the one conditional drop-down menu.

Here is the drop-down exit macro which I am assuming where the additional code needs to go. I have tried to write it and failed miserably.

Code:
Sub LockDD1()
'
' Exit macro
'
'

Dim Prot As Variant, BmkRng As Range
Const BmkNm As String = "Column" ' The bookmark name
With ActiveDocument
  Prot = .ProtectionType
  If .ProtectionType <> wdNoProtection Then
    Prot = .ProtectionType
    .Unprotect Password:=Pwd
  End If
  If .Bookmarks.Exists(BmkNm) Then
    Set BmkRng = .Bookmarks(BmkNm).Range
    If .FormFields("DD1").Result = "1790" Then
      .FormFields.Add BmkRng, wdFieldFormTextInput
      BmkRng.FormFields(1).TextInput.EditType wdRegularText, "X,"
      Else
      BmkRng.Delete
End If
    .Bookmarks.Add BmkNm, BmkRng
  Else
    MsgBox "Bookmark: " & BmkNm & " not found."
  End If
  .Protect Type:=Prot, NoReset:=True
End With
Set BmkRng = Nothing

     Application.ScreenUpdating = False
    If ActiveWindow.View.Type = wdPageView Then
        ActiveWindow.ActivePane.View.Type = wdNormalView
    Else
        ActiveWindow.View.Type = wdPageView
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Then
        ActiveWindow.ActivePane.View.Type = wdPageView
    Else
        ActiveWindow.ActivePane.View.Type = wdNormalView
    End If
    End Sub
BTW kudos to you and being self taught-I too am self taught but at least a couple of light-years behind-Thanks
Attached Files
File Type: docx Latest EE Updates for U.S. Census.docx (125.8 KB, 14 views)
Reply With Quote