Author Topic: Changing line colour doesn't work and Themeguard and variables gives an error  (Read 108 times)

0 Members and 1 Guest are viewing this topic.


  • Jr. Member
  • **
  • Posts: 21

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

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2947
    • Paul Herber's website
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.
Electronic and Electrical engineering, business and software stencils and applications for Visio -


  • Jr. Member
  • **
  • Posts: 21
thanks Paul,

that solution worked perfectly,

kind regards