J
Jacques
Hi, I am programming a form and gets "Microsoft Office Word has encountered a
problem and needs to close. We are sorry for the inconvnience message", when
I am using an arrow to get to the next field. It works fines if I use Tab. I
have an exit macro on the field I am leaving that is color coding the field
depending on the entry.
This is the code:
Sub Stat_Color_Contract()
'
' Change_Status_Color Macro
'
Dim status As String
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
status = ActiveDocument.FormFields("Status_Contract").Result
Selection.GoTo What:=wdGoToBookmark, Name:="Status_Contract"
If status = "Green" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorBrightGreen
End With
End If
If status = "Yellow" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorYellow
End With
End If
If status = "Red" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorRed
End With
End If
'Reprotect the document.
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""
End Sub
Can you help me?
Thanks,
Jacques
problem and needs to close. We are sorry for the inconvnience message", when
I am using an arrow to get to the next field. It works fines if I use Tab. I
have an exit macro on the field I am leaving that is color coding the field
depending on the entry.
This is the code:
Sub Stat_Color_Contract()
'
' Change_Status_Color Macro
'
Dim status As String
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
status = ActiveDocument.FormFields("Status_Contract").Result
Selection.GoTo What:=wdGoToBookmark, Name:="Status_Contract"
If status = "Green" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorBrightGreen
End With
End If
If status = "Yellow" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorYellow
End With
End If
If status = "Red" Then
With Selection.Cells.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorRed
End With
End If
'Reprotect the document.
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""
End Sub
Can you help me?
Thanks,
Jacques