Why is macro for exporting DWG repeating sheets?

Hi everyone, I have a macro to export DWG and PDF of each of the drawings I have open in my Solidworks. It used to work perfectly but for some reason now when I have more than one sheet in a drawing, it exports all the sheets several times adding "00, 01, 02" etc at the beginning.... this only happens with the DWGs and not with the PDF.

Does anyone know how to solve it? I'm attaching the macro and a screenshot of the problem. Many thanks in advance!

SolidworksApi macros