H
H
HParaLoN2015-02-16 09:20:41
.NET
HParaLoN, 2015-02-16 09:20:41

How to organize iteration of text styles in Excel C#?

Good afternoon. On my sore head, I decided to try to rewrite VBA macros into Microsoft Excel add-ins. But there were more problems than I thought. Maybe someone came across this, how to iterate through all styles and check if this style exists in the list. If it doesn't exist, then create it. Simply destroying the style and re-creating it will not help, since I will need it to find cells with this style. Thank you in advance.
PS solution found. If anyone is interested:
foreach (Excel.Style styleN in Globals.ThisAddIn.Application.ActiveWorkbook.Styles)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Pukhov, 2015-02-16
@Neuroware

Need to clarify what is meant by style in the context of the task?
ps most of the VBA code is rewritten 1 to 1 in the add-in syntax, the objects are the same there.

H
HParaLoN, 2015-02-16
@HParaLoN

Oh yes exactly. Normal text style.
When the button is clicked, a style is created:
Excel.Style style = Globals.ThisAddIn.Application.ActiveWorkbook.Styles.Add("Title");
The problem is that in this or that document this style may or may not exist, so a check for its existence is necessary.
PS 1v1? for some reason it didn’t seem so to me, okay if it gets really bad I’ll take a look. Thanks for the tip.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question