none
An XLL that crashes Excel when dragging a sheet to another workbook

    Question

  • Hello,

    Below are the steps describing how to create a project and reproduce the issue.

    Step 1. Modify a sample project from Excel 2013 SDK.

    Open Example.vcxproj from the SDK and modify EXAMPLE.C as follows below. You can also download the project at http://temp.add-in-express.com/support/test/Excel2013XLLSDK_OnCalcErrorDemo.zip. It's ~810 Kb and it contains a sample workbook which is used below.

    1.1. Replace

    #define rgFuncsRows 29

    with

    #define rgFuncsRows 30

    1.2. Add a new element to static LPWSTR rgFuncs[rgFuncsRows][7]:

    {L"OnCalc",					    L"", L"OnCalc"},

    1.3. Replace int WINAPI xlAutoOpen(void) with this code:

    __declspec(dllexport) int WINAPI xlAutoOpen(void)
    {

    static XLOPER12 xDLL; /* name of this DLL */ int i; /* Loop index */ Excel12f(xlGetName, &xDLL, 0); for (i=0;i<rgFuncsRows;i++) { if (wcslen(rgFuncs[i][1]) == 0) { Excel12f(xlfRegister, 0, 6, (LPXLOPER12)&xDLL, (LPXLOPER12)TempStr12(rgFuncs[i][0]), (LPXLOPER12)TempStr12(rgFuncs[i][1]), (LPXLOPER12)TempStr12(rgFuncs[i][2]), (LPXLOPER12)TempStr12(L""), TempInt12(2)); Excel12f(xlEventRegister, 0, 2, (LPXLOPER12)TempStr12(rgFuncs[i][0]), TempInt12(xleventCalculationEnded)); } else { Excel12f(xlfRegister, 0, 4, (LPXLOPER12)&xDLL, (LPXLOPER12)TempStr12(rgFuncs[i][0]), (LPXLOPER12)TempStr12(rgFuncs[i][1]), (LPXLOPER12)TempStr12(rgFuncs[i][2])); } } /* Free the XLL filename */ Excel12f(xlFree, 0, 1, (LPXLOPER12)&xDLL); return 1;

    }

    1.4. Replace LPXLOPER12 WINAPI xlAutoRegister12(LPXLOPER12 pxName) with this code:

    __declspec(dllexport) LPXLOPER12 WINAPI xlAutoRegister12(LPXLOPER12 pxName)
    {

    static XLOPER12 xDLL, xRegId; int i; xRegId.xltype = xltypeErr; xRegId.val.err = xlerrValue; for (i = 0; i < rgFuncsRows; i++) { if (!lpwstricmp(rgFuncs[i][0], pxName->val.str)) { Excel12f(xlGetName, &xDLL, 0); Excel12f(xlfRegister, 0, 4, (LPXLOPER12)&xDLL, (LPXLOPER12)TempStr12(rgFuncs[i][0]), (LPXLOPER12)TempStr12(rgFuncs[i][1]), (LPXLOPER12)TempStr12(rgFuncs[i][2])); /* Free the XLL filename */ Excel12f(xlFree, 0, 1, (LPXLOPER12)&xDLL); return (LPXLOPER12)&xRegId; } } //Word of caution - returning static XLOPERs/XLOPER12s is not thread safe //for UDFs declared as thread safe, use alternate memory allocation mechanisms return (LPXLOPER12)&xRegId;

    }

    1.5. Add this method (it's empty as you can see):

    __declspec(dllexport) void WINAPI OnCalc()
    {
    }

    Step 2. Build the project, start Excel, open the Add-ins dialog, and click the Browse button, to add the DLL built by the above project.

    Step 3. Open the workbook supplied with the above-mentioned download. The workbook's file name is FF.xlsx; it contains a single worksheet summing up some numbers.

    Step 4. Open another workbook (new or existing) and drag the worksheet from step #3 onto this workbook. Typically Excel crashes here. Alternatively, you may get this error message:

    There isn't enough memory to complete this action.
    Try using less data or closing other applications.
    To increase memory availability, consider:
     - Using a 64-bit version of Microsoft Excel.
     - Adding memory to your device.

    If you get the message, Excel crashes when you click OK.

    Excel 2013 15.0.4693.1000 32 bit and 64 bit. We were informed the issue also occurs in Excel 2010.

    Please let me know if there's something that we miss.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, March 4, 2015 1:57 PM

Answers

  • Hello Andrei,

    I am able to reproduce the issue. This seems to be a bug and I will report this.

    Thanks.

    • Marked as answer by Andrei Smolin Wednesday, March 25, 2015 5:44 AM
    Tuesday, March 24, 2015 10:46 PM

All replies

  • Hi Andrei,

    Thank you for posting in the MSDN Forum.
     
    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.
     
    Sorry for any inconvenience and have a nice day!

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 9, 2015 8:14 AM
    Moderator
  • Thank you, Fei!


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Monday, March 9, 2015 8:54 AM
  • Hello Andrei,

    I am able to reproduce the issue. This seems to be a bug and I will report this.

    Thanks.

    • Marked as answer by Andrei Smolin Wednesday, March 25, 2015 5:44 AM
    Tuesday, March 24, 2015 10:46 PM
  • Thanks for confirming.

    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, March 25, 2015 5:43 AM