Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Running a excel marco crash when passing a com variant

$
0
0

When running our application, it is crashing in the following line of code, *pResult = g_pExcel->Run(Temp1,argVariant);

Below is the code. I am not able to find why it is crashing. Is there any type conversion problem?

CExec::CallRunVbtFunc(BSTR MacroName,
                        SAFEARRAY** ArgVals,
                        int *pResult)
  {

      _bstr_t Temp1 (MacroName);

      CComVariant argVariant(*ArgVals);
      argVariant.vt = VT_ARRAY | VT_BSTR;

      *pResult = g_pExcel->Run(Temp1,
                               argVariant);

      return S_OK;
  }

Public Function MyTesting() As Long
    Dim aa(1) As String
    aa(0) = "aaa"
    aa(1) = "bbb"        

    TheExec.CallRunVbtFunc "Macro3", aa

    End Function

Sub Macro3(argc As String, argv As String)

    TheExec.WriteComment "Called Macro2 with args*************** "

End Sub

Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>