(Simple I hope) Custom name from spread designer

Posted by: kingmanb on 8 September 2017, 3:25 pm EST

  • Posted 8 September 2017, 3:25 pm EST

    How do I address a custom name added in the spread designer. If I add a name in code it works, otherwise, not so much:
    Public Class Form1
    Private Sub RibbonButton1_Click(sender As Object, e As EventArgs) Handles RibbonButton1.Click
    FpSpread1.Sheets(0).AddCustomName("Foo", "$B$3", 0, 0)
    Dim c = FpSpread1.Sheets(0).Cells("Foo")
    c.Text = "I work just fine"
    'this is a custom name added in the spread designer
    c = FpSpread1.Sheets(0).Cells("BAR")
    c.Text = "This doesn't work"
    End Sub
    End Class
  • Replied 8 September 2017, 3:25 pm EST


    Using a string indexer for Cells will search for that string in the Tag property, which is different from custom names. The Tag property for Cell works like the Control.Tag property except that it applies to the specific cell, and moves around with it when the cell is shifted from inserts or deletes or copied and pasted.

    If you use the Name Manager dialog in design time within the Spread Designer tool, or in run time by showing the dialog with ShowListCustomNameForm, then you need to use
    GetCustomNameEnumerator to get the IEnumerator for the custom name strings, then use GetCustomName to get the string formula value associated with the name.

  • Replied 8 September 2017, 3:25 pm EST

    I am not sure I'm getting it. After I set up a name using the name manager in the spread designer:
    Let's say the name is "CurrentIncome" that "refers to" =Sheet1!R5C3 scope Workbook
    isn't there a way to load value 100 into that cell at run time through
  • Replied 8 September 2017, 3:25 pm EST


    I am able to replicate this issue at my end. I have reported this to the development team as a bug.Tracking ID for this issue is :236353.
    I will let you know as soon as I get any information about the same.

    Deepak Sharma
  • Marked as Answer

    Replied 8 September 2017, 3:25 pm EST


    This has been identified as a designed behavior of Spread. The indexer for Cells that takes a string argument searches for the specified string in the Cell.Tag and doesn't use custom names.
    If we use the code "spread1.sheets(0).cells(“CurrentIncome”).value=100" the indexer will look for the Cell with a Tag "CurrentIncome" and not the cell name.

    You can make this work by setting the Cell.Tag to "CurrentIncome".

    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels