Note that there are some explanatory texts on larger screens.

plurals
  1. PORange Validator in Excel with custom message text
    primarykey
    data
    text
    <p>I have the following code to give a Excel cell Validation with custom text.</p> <pre><code>var cellValues = activeSheet.Range[columnLetterValue + startingRow, Type.Missing]; cellValues.Validation.Add(XlDVType.xlValidateCustom, XlDVAlertStyle.xlValidAlertInformation, XlFormatConditionOperator.xlBetween, cellValues.Value2, Type.Missing); cellValues.Validation.IgnoreBlank = true; cellValues.Validation.ErrorTitle = "Custom error title"; cellValues.Validation.ErrorMessage = "Custom error message description"; cellValues.Validation.ShowError = true; cellValues.Validation.ShowInput = false; </code></pre> <p>When debugging the line to set the ErrorTitle or ErrorMessage a <code>'System.Runtime.InteropServices.COMException'</code> is thrown.</p> <p>Stacktrace:</p> <blockquote> <p>{System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at<br> System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&amp; msgData) at<br> Microsoft.Office.Interop.Excel.Validation.set_ErrorTitle(String )</p> </blockquote> <p>I have looked online and found a couple of examples that show this is possible: <a href="https://stackoverflow.com/questions/3317307/range-validation-with-excel-using-c-sharp">Range Validation with Excel using C#</a></p> <p>I've even recorded a Macro in Excel and it works with the "VBA" equivilent code:</p> <pre><code> ActiveCell.FormulaR1C1 = "Custom" Range("A1").Select With Selection.Validation .Delete .Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertInformation, _ Operator:=xlBetween, Formula1:="Custom" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "UDF Title" .InputMessage = "" .ErrorMessage = "The message" .ShowInput = False .ShowError = True End With End Sub </code></pre> <p>I've also tried different combinations of XlDVType and XlFormatConditionOperator but that didn't seem to make any difference in setting the custom messagebox text.</p> <p><strong>Does anyone know how to set a Validation rule with custom ErrorTitle and ErrorMessage?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload