Hello Friends,
I need a little help
I'm develop a dll that connect with Excel, for this I use a AutoWrap funtion (https://docs.microsoft.com/en-us/office/troubleshoot/office-developer/automate-excel-from-c). I can already open the excel file and write data into the cells, but now i need run a macro. I'm using the next code:
VARIANT res; VariantInit(&res); VARIANT methodName; VariantInit(&methodName); methodName.bstrVal = CharToBSTR("All_combined");//CharToBSTR function it's mine hr = AutoWrap(DISPATCH_METHOD, &res, pXlApp, L"Run", 1,methodName); BSTR CharToBSTR(char* cadena) { int wslen = MultiByteToWideChar(CP_ACP, 0, cadena, strlen(cadena), 0, 0); BSTR bstr = SysAllocStringLen(0, wslen); MultiByteToWideChar(CP_ACP, 0, cadena, strlen(cadena), bstr, wslen); return bstr; }
Now, this code does not throw an error, but neither run the macro!
I don't know where are my error
Thank you for your replies,