Hi,
I have an object whose line colour I'd like to change.
When I record a macro it uses 'THEMEGUARD". If I then try to substitute the integers in the RGB part with a variable (I want to read values from elsewhere and apply them) I get a run-time error '2032466907 (86db0425)'.
If I remove the Themeguard part and leave just RGB with a variable it changes the colour but not to the correct colour (red as 255,0,0), it changes to black instead (0,0,0)!
The object is part of a group, if that has any influence?
Sub Macro2()
'Enable diagram services
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150
Dim UndoScopeID1 As Long
Dim x As Integer
x = 255
UndoScopeID1 = Application.BeginUndoScope("Line Color")
Application.ActiveWindow.Page.Shapes.ItemFromID(623).CellsSRC(visSectionObject, visRowLine, visLineColor).FormulaU = "THEMEGUARD(RGB(x, 0, 0))"
Application.EndUndoScope UndoScopeID1, True
'Restore diagram services
ActiveDocument.DiagramServicesEnabled = DiagramServices
End Sub
many thanks
Matthew
Problem is that your code is not using the value 255 within the formula, it is just taking the literal x. I think you need something like:
= "THEMEGUARD(RGB(" & x & ", 0, 0))"
and you will need to make x a string.
thanks Paul,
that solution worked perfectly,
kind regards
Matthew