Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAxObject - transfer code from vba to qt
Forum Updated to NodeBB v4.3 + New Features

QAxObject - transfer code from vba to qt

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 2 Posters 1.2k Views
  • 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.
  • D Offline
    D Offline
    Damian7546
    wrote on last edited by Damian7546
    #3

    @JonB @JonB you are right, above examle works, but this one not:

    oGT->dynamicCall("Wczytaj(string)", "C:\ProgramData\InsERT\InsERT GT\Subiekt2.xml");
    
    JonBJ 1 Reply Last reply
    0
    • D Damian7546

      @JonB @JonB you are right, above examle works, but this one not:

      oGT->dynamicCall("Wczytaj(string)", "C:\ProgramData\InsERT\InsERT GT\Subiekt2.xml");
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @Damian7546
      Not surprising since "C:\ProgramData\InsERT\InsERT GT\Subiekt2.xml" is not a legitimate C++ string literal, or at least does not produce what you think it produces....

      1 Reply Last reply
      2
      • D Offline
        D Offline
        Damian7546
        wrote on last edited by
        #5

        ok, it seems to be working:

        QAxObject *oGT = new QAxObject("InsERT.gt");
        oGT->setProperty("Produkt", 1);
        oGT->dynamicCall("Wczytaj(string)", "C:\\ProgramData\\InsERT\\InsERT GT\\Subiekt2.xml");
        QAxObject *oSubiekt = oGT->querySubObject("Uruchom(int, int)", 0, 0);
        
        1 Reply Last reply
        2
        • D Damian7546 has marked this topic as solved on
        • D Offline
          D Offline
          Damian7546
          wrote on last edited by
          #6

          Still problems:

          Below part of code in .VBA:

          oSubGT.Okno.Widoczne = False          
          Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
          Set oSubPoz = oSubDok.Pozycje.Dodaj(23)
          oSubPoz.IloscJm = 13
          oSubPoz.WartoscBruttoPoRabacie = 1000
          

          And below transfered to qt C++:

          QAxObject *Okno = oSubGT->querySubObject("Okno");
          Okno->setProperty("Widoczne", false);
          
          QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
          oSubDok->dynamicCall("Dodaj(int)",0xFFFFFFF7); //gtaSubiektDokumentPA=0xFFFFFFF7
          
          QAxObject* oSubPoz = oSubDok->querySubObject("Pozycje");
          oSubPoz->dynamicCall("Dodaj(int)", 24);
          
          oSubPoz->setProperty("IloscJm", 13);
          oSubPoz->setProperty("WartoscBruttoPoRabacie", 1000);
          

          but something went wrong:
          QAxBase::dynamicCallHelper: Pozycje: No such property in [unknown]
          Candidates are:

          JonBJ 1 Reply Last reply
          0
          • D Damian7546

            Still problems:

            Below part of code in .VBA:

            oSubGT.Okno.Widoczne = False          
            Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
            Set oSubPoz = oSubDok.Pozycje.Dodaj(23)
            oSubPoz.IloscJm = 13
            oSubPoz.WartoscBruttoPoRabacie = 1000
            

            And below transfered to qt C++:

            QAxObject *Okno = oSubGT->querySubObject("Okno");
            Okno->setProperty("Widoczne", false);
            
            QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
            oSubDok->dynamicCall("Dodaj(int)",0xFFFFFFF7); //gtaSubiektDokumentPA=0xFFFFFFF7
            
            QAxObject* oSubPoz = oSubDok->querySubObject("Pozycje");
            oSubPoz->dynamicCall("Dodaj(int)", 24);
            
            oSubPoz->setProperty("IloscJm", 13);
            oSubPoz->setProperty("WartoscBruttoPoRabacie", 1000);
            

            but something went wrong:
            QAxBase::dynamicCallHelper: Pozycje: No such property in [unknown]
            Candidates are:

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #7

            @Damian7546

            Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
            
            QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
            oSubDok->dynamicCall("Dodaj(int)",0xFFFFFFF7); //gtaSubiektDokumentPA=0xFFFFFFF7
            
            QAxObject* oSubPoz = oSubDok->querySubObject("Pozycje");
            oSubPoz->dynamicCall("Dodaj(int)", 24);
            

            The C++ code does not do the same as the VBA code. Please look at it carefully.

            In the VBA oSubDok is set to the result of oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA). But in the C++ oSubDok is only to set to oSubGT.Dokumenty. You call Dodaj() on that but you do not use that as the resulting object to then call oSubDok->querySubObject("Pozycje") on. Hence querySubObject("Pozycje") is not found in oSubDok because that is oSubGT.Dokumenty rather than oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA).

            Please follow the VBA code more accurately when translating to C++.

            1 Reply Last reply
            1
            • D Offline
              D Offline
              Damian7546
              wrote on last edited by
              #8

              I followed your advice and change below VBA :

              Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
              Set oSubPoz = oSubDok.Pozycje.Dodaj(23)
              oSubPoz.IloscJm = 13
              oSubPoz.WartoscBruttoPoRabacie = 1000
                     
              oSubDok.Wyswietl
              oSubDok.Zamknij
              

              to C++ code :

                  QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
                  QAxObject* oSubDokDod = oSubDok->querySubObject("Dodaj(int)",0xFFFFFFF7);
              
                  QAxObject* oSubPoz = oSubDokDod->querySubObject("Pozycje");
                  QAxObject* oSubPozDod = oSubPoz->querySubObject("Dodaj(int)", 23);
              
                  oSubPozDod->setProperty("IloscJm", 13);
                  oSubPozDod->setProperty("WartoscBruttoPoRabacie", 1000);
              
                  oSubDokDod->dynamicCall("Wyswietl");
                  oSubDokDod->dynamicCall("Zamknij");
              

              But stil is some wrong:
              QAxBase: Error calling IDispatch member Wyswietl: Member not found
              QAxBase: Error calling IDispatch member Zamknij: Member not found

              JonBJ 1 Reply Last reply
              0
              • D Damian7546

                I followed your advice and change below VBA :

                Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
                Set oSubPoz = oSubDok.Pozycje.Dodaj(23)
                oSubPoz.IloscJm = 13
                oSubPoz.WartoscBruttoPoRabacie = 1000
                       
                oSubDok.Wyswietl
                oSubDok.Zamknij
                

                to C++ code :

                    QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
                    QAxObject* oSubDokDod = oSubDok->querySubObject("Dodaj(int)",0xFFFFFFF7);
                
                    QAxObject* oSubPoz = oSubDokDod->querySubObject("Pozycje");
                    QAxObject* oSubPozDod = oSubPoz->querySubObject("Dodaj(int)", 23);
                
                    oSubPozDod->setProperty("IloscJm", 13);
                    oSubPozDod->setProperty("WartoscBruttoPoRabacie", 1000);
                
                    oSubDokDod->dynamicCall("Wyswietl");
                    oSubDokDod->dynamicCall("Zamknij");
                

                But stil is some wrong:
                QAxBase: Error calling IDispatch member Wyswietl: Member not found
                QAxBase: Error calling IDispatch member Zamknij: Member not found

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #9

                @Damian7546
                The last two items are (apparently) properties, like those set with your setProperty() calls, so try oSubDokDod->property("Wyswietl")? Or maybe they don't exist, I don't know.

                You are making the translation from VBA to C++ harder/unclear by your choice of variable name in the C++ not corresponding exactly to the VBA.

                Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
                
                    QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
                    QAxObject* oSubDokDod = oSubDok->querySubObject("Dodaj(int)",0xFFFFFFF7);
                

                Make your C++ oSubDok refer to exactly the same object as the VBA oSubDok. Don't name it oSubDokDod, that's unhelpful, instead use some other name for the intermediate QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty"); variable which does not exist in the VBA.

                D 1 Reply Last reply
                0
                • JonBJ JonB

                  @Damian7546
                  The last two items are (apparently) properties, like those set with your setProperty() calls, so try oSubDokDod->property("Wyswietl")? Or maybe they don't exist, I don't know.

                  You are making the translation from VBA to C++ harder/unclear by your choice of variable name in the C++ not corresponding exactly to the VBA.

                  Set oSubDok = oSubGT.Dokumenty.Dodaj(gtaSubiektDokumentPA)
                  
                      QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty");
                      QAxObject* oSubDokDod = oSubDok->querySubObject("Dodaj(int)",0xFFFFFFF7);
                  

                  Make your C++ oSubDok refer to exactly the same object as the VBA oSubDok. Don't name it oSubDokDod, that's unhelpful, instead use some other name for the intermediate QAxObject* oSubDok = oSubGT->querySubObject("Dokumenty"); variable which does not exist in the VBA.

                  D Offline
                  D Offline
                  Damian7546
                  wrote on last edited by
                  #10

                  @JonB said in QAxObject - transfer code from vba to qt:

                  You are making the translation from VBA to C++ harder/unclear by your choice of variable name in the C++ not corresponding exactly to the VBA.

                  you are right.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Damian7546
                    wrote on last edited by
                    #11

                    @JonB in your opinion how I should change below code:

                    Function UruchomSubiekta() As InsERT.Subiekt
                    	... 
                    End Function
                    
                    
                    
                    Sub FS()
                    	Dim oSubGT As InsERT.Subiekt
                    	Set oSubGT = UruchomSubiekta()
                    End Sub
                    
                    JonBJ 1 Reply Last reply
                    0
                    • D Damian7546

                      @JonB in your opinion how I should change below code:

                      Function UruchomSubiekta() As InsERT.Subiekt
                      	... 
                      End Function
                      
                      
                      
                      Sub FS()
                      	Dim oSubGT As InsERT.Subiekt
                      	Set oSubGT = UruchomSubiekta()
                      End Sub
                      
                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #12

                      @Damian7546
                      Now you are going beyond my knowledge. I don't even use Windows, I just know how to do COM/Automation/VBA stuff from many years ago.

                      You seem to be defining your own Functions & Subs in VBA. I don't know how or whether you can do that from C++. It may not be possible, it may be a "feature" of VB/VBA to add user defined functions/procedures. I don't know if you can "extend" ActiveX objects from C++. You could presumably manage by putting in all the C++ code without defining it as ActiveX functions, or factor it into functions you can call in C++ without it actually "extending" the ActiveX object in any way.

                      At the end of the day these are not really questions about Qt. You know what you have available from QAxObject in Qt, that is all you have.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved