how can I address an Excel dialog for the color palette via C# so that the user can select a cell color, for example?
In VBA this could be done with the following code:
If Application.Dialogs(84).Show <> False Then
varColor = .Cells(3, enuFormatting.CellColor).Interior.Color
'Convert Color to RGB
modul.Color_RGB varColor, intRed, intGreen, intBlue
'Preview
Me.lbl_FormatFont.BackColor = RGB(intRed, intGreen, intBlue)
End If
Public Sub Color_RGB(ByVal varColor As Variant, ByRef intRed As Integer, ByRef intGreen As Integer, ByRef intBlue As Integer)
'Convert color index to RGB
On Error Resume Next
intRed = varColor Mod 256
varColor = (varColor - intRed) / 256
intGreen = varColor Mod 256
varColor = (varColor - intGreen) / 256
intBlue = varColor Mod 256
End Sub
Greetings
You may get the collection of all the Dialog objects in Microsoft Excel:
Application excel = new Microsoft.Office.Interop.Excel.Application();
...
Dialogs dialogs = excel.Dialogs;
and then you get the xlDialogPatterns
and invoke the Show()
method:
dialogs.Item[XlBuiltInDialog.xlDialogPatterns].Show();