View Single Post
  #1   Report Post  
WordNoob WordNoob is offline
Junior Member
 
Posts: 0
Default Help with Drop Down Macro to select Document Background Color

So I am trying to create and office memo template and as part of this based on what the memo is for, the user of the form selects the purpose and it changes the background color of the document.

So I created a Drop-Down List Content Control Named "BackgroundColor" with the Values "Blue" and "Green" for 2 different purposes.

I then wrote a VBA Macro as follows

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
ActiveDocument.Unprotect
With ActiveDocument
Select Case ActiveDocument.ContentControls("BackgroundColor")
Case "Blue"
ActiveDocument.ActiveWindow.View.DisplayBackground s = True
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(200, 200, 200)
ActiveDocument.Background.Fill.Transparency = 0#
ActiveDocument.Background.Fill.PresetTextured msoTextureParchment
Case "Green"
ActiveDocument.ActiveWindow.View.DisplayBackground s = True
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(100, 100, 100)
ActiveDocument.Background.Fill.Transparency = 0#
ActiveDocument.Background.Fill.PresetTextured msoTextureParchment
Case Else
End Select
ActiveDocument.Protect wdAllowOnlyFormFields, True
End With
End Sub

The Macro fails with Invalid Parameter. Anyone have any idea how to fix it?

I am on Office Professional Plus 2016

Last edited by WordNoob : August 20th 18 at 04:58 PM