Amended the file in the link slightly you provided (
https://vborg.vbsupport.ru/showthread.php?t=65114 ),
to use vb's db connection etc.
Should work how you want it to, if you put in the proper chdir.
But the code is not efficient, queries in loops.
Edit: Untested, use at own risk. That said, I believe there are other threads out there which does the same thing as well.