If I run the macro sometimes it comes sometimes not.
The error is here, it has something to do with sw.Doc I think.
bDocWasVisible = swDoc.Visible
swApp.ActivateDoc swDoc.GetPathName
Attached is the code as a text file. If one wants to run it you have to open an assembly (or part) in solidworks.
And you need to have a folder "K:\Konstruk\temp\STPundDWG\" or you change this path
in line EingegebenerDateiPfad_2 = "K:\Konstruk\temp\STPundDWG\" to a path that exists on your drive.
Thank you.