The issue is because you have removed the two lines of code from the script shared in the MSFT link.
You cannot remove something from the code and expect it to work fine 🙂
Add those two lines and
also make objExcel.Application.Visible = False
so that the opening and closing of Excel by vbscript will not be visible.