![]() |
|
#1
|
|||
|
|||
|
new to vba macros , im trying to create a dropmenu that does a few different things, depending on the choice it'll convert the color of the severity then itll tally all the dropemnus and itll update a table thats attached to a graph. so far I have the colors working with the code below
![]() ![]() ![]() Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl.Range
If ContentControl.Title = "Severity" Then
Select Case .Text
Case "Critical"
.Cells(1).Shading.BackgroundPatternColor = wdColorDarkRed
.Font.Color = wdColorWhite
.Font.Bold = True
Case "High"
.Cells(1).Shading.BackgroundPatternColor = wdColorRed
.Font.Color = wdColorBlack
.Font.Bold = True
Case "Medium"
.Cells(1).Shading.BackgroundPatternColor = wdColorOrange
.Font.Color = wdColorBlack
.Font.Bold = True
Case "Low"
.Cells(1).Shading.BackgroundPatternColor = wdColorYellow
.Font.Color = wdColorBlack
.Font.Bold = True
Case "Informational"
.Cells(1).Shading.BackgroundPatternColor = wdColorLightBlue
.Font.Color = wdColorBlack
.Font.Bold = True
Case Else
.Cells(1).Shading.BackgroundPatternColor = wdColorAutomatic
End Select
End If
End With
End Sub
The chart and table look like this ![]() if i edit the graph data it'll look like this ![]() i think the code to update the table should look like something like this Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim Total As Long, i As Long
Total = 0
With Selection.Rows(1)
For i = 1 To 6
Select Case .Cells(i).Range.ContentControls(1).Range.Text
Case "Critical"
Critical = Critical + 1
Total = Total + 1
Case "High"
High = High + 1
Total = Total + 1
Case "Medium"
Medium = Medium + 1
Total = Total + 1
Case "Low"
Low = Low + 1
Total = Total + 1
Case "Informational"
Informational = Informational + 1
Total = Total + 1
End Select
Next i
.Cells(8).Range.Text = Total
End With
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word Macro to update the layout of document | joaoossilva | Word VBA | 4 | 11-07-2016 01:11 PM |
| How can I use a Macro to automatically update all the pictures in a word doc | GezLundy | Word VBA | 3 | 06-12-2014 03:23 AM |
Document_ContentControlOnExit
|
Catty | Word VBA | 2 | 11-29-2013 04:49 AM |
Update Word table based on another table input
|
mpdsal | Word VBA | 10 | 10-29-2012 07:40 AM |
| How do you update existing Outlook calendar item from Word with macro? | Joe Patrick | Word VBA | 0 | 07-09-2011 05:32 AM |