I have a problem with porting VBA code to Lazarus - OleVariant enumeration lazarus / 21-General ---------------------------------------------------------------------- Sylwester · 2022-02-17 13:00 Code VBA QuoteSub 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 and code LAZARUS Quoteunit 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,gtaFiltrS uDokumentZam: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 can't make a loop to enumerate OleVariant - oListGT. MarkedDocuments What to do to get to the value oDok ---------------------------------------------------------------------- marcov · 2022-02-17 13:55 Have a look at https://www.stack.nl/~marcov/wmishowwinver.zip and the unit wmiutil in there. (and the other file demonstrates) It allows to do olevariant enum with for..in ---------------------------------------------------------------------- Sylwester · 2022-02-18 06:23 This link not working - please send by google drive or other. ---------------------------------------------------------------------- Thaddy · 2022-02-18 08:42 The link does not work indeed. May be just https ? ---------------------------------------------------------------------- marcov · 2022-02-18 08:43 Corrected the link ---------------------------------------------------------------------- Sylwester · 2022-02-18 09:14 Not working link - please correct this  becouse is important for me. ---------------------------------------------------------------------- WooBean · 2022-02-18 09:35 First shot "delphi iterate enumeration" in Google service  leads us to https://stackoverflow.com/questions/1600575/iterate-through-items-in- an-enumeration-in-delphi/1600600 where you can find: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TWeekdays = (wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday); procedure Test;var  el: TWeekdays;begin  for el := Low(TWeekdays) to High(TWeekdays) do    ; //end;  Is it enough? ---------------------------------------------------------------------- marcov · 2022-02-18 10:17 Quote from: WooBean on February 18, 2022, 10:35:55 amIs it enough? It is about enumerating an olevariant, not an enumerate an enumeration. IOW different type. Note that my link afaik also works with delphi ---------------------------------------------------------------------- paweld · 2022-02-18 10:31 another link: https://forum.lazarus.freepascal.org/index.php?action=dl attach;topic=48501.0;attach=35424 ---------------------------------------------------------------------- Sylwester · 2022-02-18 10:53 It is working good - super - thanks for oDok in oEnum.Enumerate(oListGT.ZaznaczoneDokumenty) do     ShowMessage(VarToStr(oDok.Identyfikator));