'I have a problem with porting VBA code to Lazarus
Sub ListaDokumentow()
On Error GoTo ErrHandler
Dim oSubGT As InsERT.Subiekt
Dim oListaDok As InsERT.SuDokumentyLista
Dim oDok As InsERT.SuDokument
Dim sNapis As String
Set oSubGT = UruchomSubiekta()
Set oListaDok = oSubGT.Dokumenty.Wybierz()
oListaDok.FiltrTypOpcje = gtaFiltrSuDokumentOpcjeZam
oListaDok.FiltrTyp = gtaFiltrSuDokumentZam
oListaDok.FiltrOkres = gtaFiltrOkresNieokreslony
oListaDok.MultiSelekcja = True
oListaDok.Wyswietl
sNapis = "Zaznaczono nastęujące dokumenty: " & vbCrLf
For Each oDok In oListaDok.ZaznaczoneDokumenty
sNapis = sNapis & oDok.NumerPelny & "ID:" & oDok.Identyfikator & vbCrLf
Next
MsgBox sNapis
Exit Sub
ErrHandler:
MsgBox "Wystąpił błąd: " & Err.Number & " - " & Err.Description
End Sub
I wrote such a code in VBA but I can not transfer it to Lazarus, it is about returning the invoice id and the invoice number
unit sm_testy;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, wps_u, LCLType,Comobj,variants,ActiveX;
type
TOleCollectionEnumClass = class(TObject);
TEkSmTesty = class(TForm)
private
public
end;
var
EkSmTesty: TEkSmTesty;
implementation
{$R *.lfm}
var
aSubGT,oSubGT:OleVariant;
oListGT,gtaFiltrOkresNieokreslony,gtaFiltrSuDokumentOpcjeZam,gtaFiltrSuDokumentZam:OleVariant;
oDok: OleVariant;
Reply, BoxStyle: Integer;
begin
BoxStyle := MB_ICONQUESTION + MB_YESNO;
//Reply := Application.MessageBox(PChar(IntToStr(PROG_VER_NUM_RC)),'Test', BoxStyle);
wpsConnect(oSubGT,true);
oListGT:=oSubGT.Dokumenty.Wybierz;
oListGT.FiltrTypOpcje:=15;
//oListGT.FiltrTyp:=gtaFiltrSuDokumentZam;
oListGT.FiltrOkres:=gtaFiltrOkresNieokreslony;
oListGT.MultiSelekcja:= True;
oListGT.Wyswietl;
end. // eof
I stopped at the display of window of "subiekt" with the list, and I do not know how to enumerate the oleVariant object
Maybe someone would at least lead me on the right path
I can't enumerate the oDok object in Lazarus, which in my opinion should look something like this
oDok: = CreateOleObject ('InsERT.SuDokument');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
