Hi @patryk_walkusz. Nice code so far.
When I read through it, I noticed that the whole large section of code for a Windows Form could be replaced by the uniquely iLogic 'InputListBox'. That is essentially a simple, pre-designed Windows Form just for presenting a List for single selection, like what you are doing there. Below is some example code using that resource which could likely replace that section of code, to shorten and simplify the rule. All this code could have gone on one line, but I spaced it out into 3 rows using the 'space then underscore' technique, to keep side scrolling requirements to a minimum.
Dim selectedFolderName As String = InputListBox("Wybierz folder z drzewka modelu:", _
folderList, String.Empty, "Eksport BOM – wybierz podzespół", _
"Wybierz folder z drzewka modelu:", 500, 440)
As for your "piece item is global not just in folder" comment...I assume you are talking about the BOM's ItemNumber and/or BOM's ItemQuantity. If the BOM's ItemNumber is a problem, you could incorporate an Integer type variable back before the loop, then just add 1 to it every time you add a row of data to the Excel sheet, using that as the ItemNumber value. And if the BOM's ItemQuantity value is a problem, I think you could include an additional block of code that iterates through the 'selectedOccurrences' HashSet and counts how many of them represent the same source model, or same 'base name' before the index number. Then use the variable for that count in place of the ItemQuantity value when writing it to Excel. Just some thoughts.
Wesley Crihfield

(Not an Autodesk Employee)