Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. COleSafeArray

COleSafeArray

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    Whats wrong with this:

    COleSafeArray arrayField;
    arrayField.CreateOneDim(VT\_VARIANT,6);
    
    COleSafeArray arrayValues;
    arrayValues.CreateOneDim(VT\_VARIANT,6);
    
    arrayField.PutElement((long \*)0, &(\_variant\_t("LastName")));	
    arrayValues.PutElement((long \*)0,&(\_variant\_t("Mansouri")));
    

    Atg the PueElement statement it thrown an exception.But I can't see the error. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

    D 1 Reply Last reply
    0
    • M Mazdak

      Whats wrong with this:

      COleSafeArray arrayField;
      arrayField.CreateOneDim(VT\_VARIANT,6);
      
      COleSafeArray arrayValues;
      arrayValues.CreateOneDim(VT\_VARIANT,6);
      
      arrayField.PutElement((long \*)0, &(\_variant\_t("LastName")));	
      arrayValues.PutElement((long \*)0,&(\_variant\_t("Mansouri")));
      

      Atg the PueElement statement it thrown an exception.But I can't see the error. Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

      D Offline
      D Offline
      DanielO
      wrote on last edited by
      #2

      hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO

      M D 2 Replies Last reply
      0
      • D DanielO

        hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Thanks. :) Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

        1 Reply Last reply
        0
        • D DanielO

          hi, if you use a function like this where you give in strValue your "Lastname" void FillSafeArray(CString strValue, int iRow, int iCol, COleSafeArray* sa) { VARIANT v; long index[2]; index[0] = iRow; index[1] = iCol; VariantInit(&v); v.vt = VT_BSTR; v.bstrVal = strValue.AllocSysString(); sa->PutElement(index, v.bstrVal); SysFreeString(v.bstrVal); VariantClear(&v); } hope it helps, DanielO

          D Offline
          D Offline
          diptipanchal
          wrote on last edited by
          #4

          If i want to pass numerical value in FillSafeArray(int ivalue...)then what should i change in the FillSafeArray function? Why i need int value because when i use FillSafeArray(CString strValue..) the value saved in excel sheet as text even though that value is "number". I want the sum of column & since the values are stored in excel as text in 1 column & if sum formula is used for that column in excel automation, it gives sum as 0. Hence i thought of storing this value as int so that am able to use sum formula in excel automation. Is there any function to convert text to number in excel automation?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups