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. COM
  4. InvokeHelper

InvokeHelper

Scheduled Pinned Locked Moved COM
helpc++
15 Posts 3 Posters 0 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 MsmVc

    Hi All I am getting error error when i am useing InvokeHelper.Function

    Declreation in Test Header file
    VARIANT Get_List(int* SheetName);
    And Define in Cpp file of Test
    VARIANT Test::Get_List(int* SheetName)
    {
    VARIANT result;
    static BYTE parms[] =
    VTS_PI1;
    InvokeHelper(0x60030002, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
    SheetName);
    return result;
    }
    use Get_List function in main Class FinalDlg like this
    Test objXl;
    int sCol=3;
    objXl.Get_List(&sCol);

    Then i am getting

    "Type misMatch"

    in class wincore.cpp. Plz help me

    V Offline
    V Offline
    Vi2
    wrote on last edited by
    #2

    "result" variable is uninitialized.

    With best wishes, Vita

    M 1 Reply Last reply
    0
    • V Vi2

      "result" variable is uninitialized.

      With best wishes, Vita

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

      Thanks for reply. But result variable is initialize here

      VARIANT result;

      Sorry can you describe more.

      V 1 Reply Last reply
      0
      • M MsmVc

        Thanks for reply. But result variable is initialize here

        VARIANT result;

        Sorry can you describe more.

        V Offline
        V Offline
        Vi2
        wrote on last edited by
        #4

        No, this is uninitialized variable. But it doesn't help as I see the code of MFC. So, I think that VTS_PI1 is unapplicable here. Use VTS_PUI1 or VTS_PI4.

        With best wishes, Vita

        M 1 Reply Last reply
        0
        • V Vi2

          No, this is uninitialized variable. But it doesn't help as I see the code of MFC. So, I think that VTS_PI1 is unapplicable here. Use VTS_PUI1 or VTS_PI4.

          With best wishes, Vita

          M Offline
          M Offline
          MsmVc
          wrote on last edited by
          #5

          Ok i use

          VTS_PUI1 or VTS_PI4.

          both now error is same. If you need example code then i will give you.I need help.

          V 1 Reply Last reply
          0
          • M MsmVc

            Ok i use

            VTS_PUI1 or VTS_PI4.

            both now error is same. If you need example code then i will give you.I need help.

            V Offline
            V Offline
            Vi2
            wrote on last edited by
            #6

            What declaration of method 0x60030002 do you have? What is a "Test objXl"?

            With best wishes, Vita

            M 1 Reply Last reply
            0
            • V Vi2

              What declaration of method 0x60030002 do you have? What is a "Test objXl"?

              With best wishes, Vita

              M Offline
              M Offline
              MsmVc
              wrote on last edited by
              #7

              See i don't much about InvokeHelper.I had download a project from Codeproject and make new project with the help of downloaded project.I am sending you a project link which have example code and Dll. Link is here Automating Microsoft Excel and Word Together[^] I am creating a new dll and write a new function.

              Public Function Get_List(SheetNumber As Long) As String
              ' Dim myExcel As Object
              Dim Counter1 As Integer
              Dim Returnstring As String
              Dim myWorkBook As Excel.Workbook
              Dim tworksheet As Excel.Worksheet

              ' myExcel = CreateObject("Excel.Application")
              ' myWorkBook = myExcel.Workbook.Open("C:\sample.xls")

                  For Each tworksheet In myWorkBook.Worksheets
              '        Me.ListBox1.Items.Add (tworksheet.Name)
              Returnstring = tworksheet.Name
              If iindex = Counter1 Then
              Get\_List = Returnstring
              
              End If
              Counter1 = Counter1 + 1
                  Next
              

              End Function
              And try to access in vc++.Then i am getting error

              Plz help me

              V L 2 Replies Last reply
              0
              • M MsmVc

                See i don't much about InvokeHelper.I had download a project from Codeproject and make new project with the help of downloaded project.I am sending you a project link which have example code and Dll. Link is here Automating Microsoft Excel and Word Together[^] I am creating a new dll and write a new function.

                Public Function Get_List(SheetNumber As Long) As String
                ' Dim myExcel As Object
                Dim Counter1 As Integer
                Dim Returnstring As String
                Dim myWorkBook As Excel.Workbook
                Dim tworksheet As Excel.Worksheet

                ' myExcel = CreateObject("Excel.Application")
                ' myWorkBook = myExcel.Workbook.Open("C:\sample.xls")

                    For Each tworksheet In myWorkBook.Worksheets
                '        Me.ListBox1.Items.Add (tworksheet.Name)
                Returnstring = tworksheet.Name
                If iindex = Counter1 Then
                Get\_List = Returnstring
                
                End If
                Counter1 = Counter1 + 1
                    Next
                

                End Function
                And try to access in vc++.Then i am getting error

                Plz help me

                V Offline
                V Offline
                Vi2
                wrote on last edited by
                #8

                Sorry, it requires so much time which I don't have. Try to call the simpler function, for example,

                Public Function Get_List(SheetNumber As Long) As String
                Get_List = "aaa"
                End Function

                With best wishes, Vita

                M 1 Reply Last reply
                0
                • V Vi2

                  Sorry, it requires so much time which I don't have. Try to call the simpler function, for example,

                  Public Function Get_List(SheetNumber As Long) As String
                  Get_List = "aaa"
                  End Function

                  With best wishes, Vita

                  M Offline
                  M Offline
                  MsmVc
                  wrote on last edited by
                  #9

                  i am doing something wrong.See I add function in Dll

                  Public Function Get_List(SheetNumber As Long) As String
                  Get_List = "aaa"
                  End Function

                  And Declaration in m2msofficecom.h file

                  VARIANT Get_List(long* number);

                  And Define in m2msofficecom.cpp

                  VARIANT _clsExcel::Get_List(long* number)
                  {
                  VARIANT result;
                  static BYTE parms[] =
                  VTS_PI4;
                  InvokeHelper(0x60030002, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
                  number);
                  return result;
                  }

                  And Call in MainDlg Class

                  _clsExcel objXl;
                  long ty=1;
                  objXl.Get_List(&ty);

                  but still i am getting same error. plz help me.

                  V 1 Reply Last reply
                  0
                  • M MsmVc

                    i am doing something wrong.See I add function in Dll

                    Public Function Get_List(SheetNumber As Long) As String
                    Get_List = "aaa"
                    End Function

                    And Declaration in m2msofficecom.h file

                    VARIANT Get_List(long* number);

                    And Define in m2msofficecom.cpp

                    VARIANT _clsExcel::Get_List(long* number)
                    {
                    VARIANT result;
                    static BYTE parms[] =
                    VTS_PI4;
                    InvokeHelper(0x60030002, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
                    number);
                    return result;
                    }

                    And Call in MainDlg Class

                    _clsExcel objXl;
                    long ty=1;
                    objXl.Get_List(&ty);

                    but still i am getting same error. plz help me.

                    V Offline
                    V Offline
                    Vi2
                    wrote on last edited by
                    #10

                    I can only propose that 0x60030002 is not Get_List function. You can look at DLL by "Ole/COM Viewer" and find the declaration of _clsExcel interface. Can you post the direct reference to your DLL?

                    With best wishes, Vita

                    M 1 Reply Last reply
                    0
                    • V Vi2

                      I can only propose that 0x60030002 is not Get_List function. You can look at DLL by "Ole/COM Viewer" and find the declaration of _clsExcel interface. Can you post the direct reference to your DLL?

                      With best wishes, Vita

                      M Offline
                      M Offline
                      MsmVc
                      wrote on last edited by
                      #11

                      please explain in detail.i am also think about 0x60030002 is not Get_List function.But how can i find it.

                      V 1 Reply Last reply
                      0
                      • M MsmVc

                        please explain in detail.i am also think about 0x60030002 is not Get_List function.But how can i find it.

                        V Offline
                        V Offline
                        Vi2
                        wrote on last edited by
                        #12

                        VB creates the DLL, which has a TLB inside. Run the "OLE/COM Viewer" and File -> View TypeLib.... Perhaps there is a MFC Wizard which also can import this TLB into code. But I don't know about it, because I use #import directive in C++ client code.

                        With best wishes, Vita

                        M 2 Replies Last reply
                        0
                        • V Vi2

                          VB creates the DLL, which has a TLB inside. Run the "OLE/COM Viewer" and File -> View TypeLib.... Perhaps there is a MFC Wizard which also can import this TLB into code. But I don't know about it, because I use #import directive in C++ client code.

                          With best wishes, Vita

                          M Offline
                          M Offline
                          MsmVc
                          wrote on last edited by
                          #13

                          ok i am trying to do that.

                          1 Reply Last reply
                          0
                          • V Vi2

                            VB creates the DLL, which has a TLB inside. Run the "OLE/COM Viewer" and File -> View TypeLib.... Perhaps there is a MFC Wizard which also can import this TLB into code. But I don't know about it, because I use #import directive in C++ client code.

                            With best wishes, Vita

                            M Offline
                            M Offline
                            MsmVc
                            wrote on last edited by
                            #14

                            Thanks for smart ans.. Problem solved.

                            1 Reply Last reply
                            0
                            • M MsmVc

                              See i don't much about InvokeHelper.I had download a project from Codeproject and make new project with the help of downloaded project.I am sending you a project link which have example code and Dll. Link is here Automating Microsoft Excel and Word Together[^] I am creating a new dll and write a new function.

                              Public Function Get_List(SheetNumber As Long) As String
                              ' Dim myExcel As Object
                              Dim Counter1 As Integer
                              Dim Returnstring As String
                              Dim myWorkBook As Excel.Workbook
                              Dim tworksheet As Excel.Worksheet

                              ' myExcel = CreateObject("Excel.Application")
                              ' myWorkBook = myExcel.Workbook.Open("C:\sample.xls")

                                  For Each tworksheet In myWorkBook.Worksheets
                              '        Me.ListBox1.Items.Add (tworksheet.Name)
                              Returnstring = tworksheet.Name
                              If iindex = Counter1 Then
                              Get\_List = Returnstring
                              
                              End If
                              Counter1 = Counter1 + 1
                                  Next
                              

                              End Function
                              And try to access in vc++.Then i am getting error

                              Plz help me

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #15

                              :)

                              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