Hello to everyone again.
I'm sorry if I flood the forum with my request, but as said in another topic, I'm new to VBA and I'm trying to program a file to automate my office work, so that everyone can properly use it.
After the selection I'm facing another problem.
I have a drop down list of 5 elements named as protocols to follow to which I gave a hidden value through the property in the developer tab.
Then I write a macro to write the hidden value that I'll need for another instruction (because the if formula doesn't work in this file). I want the result in a specific cell of a chart, but the macro I find write the result in the row below the drop down list and it's not shown in the chart.
Another problem I'm facing is that I have more of those drop down list (like 4 or 5) and everyone has different elements with different hidden value, but I can only make the macro work for the first list.
Here's the macro
Sub Document_ContentControlOnExit()
Dim cc As ContentControl
Dim lngScore As Long
lngScore = 0
With ActiveDocument
For Each cc In ActiveDocument.ContentControls
If cc.Title = "Score" Then
Select Case cc.Range.Text
Case "Good"
lngScore = lngScore + 5
Case "Needs improvement"
lngScore = lngScore - 5
Case Else
lngScore = lngScore
End Select
End If
Next cc
.Variables("Score") = lngScore
.Range.Fields.Update
End With
End Sub
Thanks for the infinite help and patience to everyone
I'm sorry if I flood the forum with my request, but as said in another topic, I'm new to VBA and I'm trying to program a file to automate my office work, so that everyone can properly use it.
After the selection I'm facing another problem.
I have a drop down list of 5 elements named as protocols to follow to which I gave a hidden value through the property in the developer tab.
Then I write a macro to write the hidden value that I'll need for another instruction (because the if formula doesn't work in this file). I want the result in a specific cell of a chart, but the macro I find write the result in the row below the drop down list and it's not shown in the chart.
Another problem I'm facing is that I have more of those drop down list (like 4 or 5) and everyone has different elements with different hidden value, but I can only make the macro work for the first list.
Here's the macro
Sub Document_ContentControlOnExit()
Dim cc As ContentControl
Dim lngScore As Long
lngScore = 0
With ActiveDocument
For Each cc In ActiveDocument.ContentControls
If cc.Title = "Score" Then
Select Case cc.Range.Text
Case "Good"
lngScore = lngScore + 5
Case "Needs improvement"
lngScore = lngScore - 5
Case Else
lngScore = lngScore
End Select
End If
Next cc
.Variables("Score") = lngScore
.Range.Fields.Update
End With
End Sub
Thanks for the infinite help and patience to everyone