Changing line colour doesn't work and Themeguard and variables gives an error

Started by matthew, September 25, 2020, 09:23:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

matthew

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

Paul Herber

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 for Visio -

https://www.paulherber.co.uk/

matthew