Issue with program to Auto-save excel in C++

Discussion in 'C++' started by haroonrulz, Sep 4, 2012.

  1. haroonrulz

    haroonrulz Banned

    Joined:
    Aug 30, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Dear Gurus/Experts in C++,

    I am creating an automation tool, for that I have to autosave the excel with strings.I can read/write in excel, but when I try to

    auto-save the excel I am getiing error, the same code I tried for saving the integers,its working but for string I am getiing error -

    "IDispatch::GetIDsOfNames("saved")failed w/err 0x80020006". Please look at the code below and help me.

    //Auto-save for Integers -- Working

    {
    VARIANT x;
    x.vt = VT_I4;
    x.bstrVal = ::SysAllocString(L"D:\\output.xls");
    AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlBook, L"Saved", 1, x);
    }

    //Same for Strings -- Not Working

    {
    VARIANT fname;
    fname.vt = VT_BSTR;
    fname.bstrVal=::SysAllocString(L"D:\\output3.xls");
    AutoWrap(DISPATCH_METHOD, NULL, pXlBook, L"Saved", 1, fname);
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice