CopyC++
 
 
 
 
     
     
 
#pragma region SetLongFormulaIntl support code
IMPLEMENT_XLLFN4(SetLongFormulaIntl, SetLongFormulaIntl_4, 
    SetLongFormulaIntl_12, "A", "A", L"SetLongFormulaIntl", 0, L"", 0, L"14", 0,
    L"Paste a long formula to the current cell", 0, L"", 0, 0, L"{SetLongFormu"
    L"laIntl,,,Paste a long formula to the current cell,14,2,132,A,{},{},3,,0,"
    L"0,,,,0,0}", 2, 0, 0)
BOOL SetLongFormulaIntl_Impl();
extern "C" __declspec(dllexport)
BOOL SetLongFormulaIntl_12()
{
    XLL_FIX_STATE;
    return SetLongFormulaIntl_Impl();
}
extern "C" __declspec(dllexport)
BOOL SetLongFormulaIntl_4()
{
    XLL_FIX_STATE;
    return SetLongFormulaIntl_Impl();
}
#pragma endregion
BOOL SetLongFormulaIntl_Impl()
{
     
 
 
     
     
 
     
     
 
    int nChars = 200;
    int nRepeats = 4;
    char achVal1[1024];
    int i;
    for (i = 0; i < nChars; i++)
        achVal1[i] = 'A' + (i % 26);
    achVal1[i] = 0;
    CString strVal2 = "";
    for (i = 0; i < nRepeats; i++)
        strVal2 += ((i > 0) ? "&" : "") + CString("\"") + achVal1 + "\"";
    CString strFormula = "=LEFT(" + strVal2 + ", 200)";
    
    CString strMsg;
    strMsg.Format("Formula length = %d", strFormula.GetLength());
    CXllApp::XlMessageBox(strMsg, XlMessageBoxTypeInformation);
    CXlOper xloActive;
    if (xloActive.GetActiveCell()
     && xloActive.SetLongFormula(strFormula))
    {
        return TRUE;
    }
    else
    {
        CXllApp::XlMessageBox("Failed to set long formula", XlMessageBoxTypeExclamation);
        return FALSE;
    }
}
      Uses
      CXlOper::SetLongFormulaIntl