I am not exactly sure what the "swSaveAsOptions_SaveReferenced" enumeration member does but it doesn't copy all of the components referenced by the drawing to the desired directory.
I think what you're trying to accomplish requires Pack and Go. Use the IPackAndGo interface. I will note, however, that this interface has a lot of bugs so you might not be able to accomplish exactly what you need.
There are several examples in the API Help, but for a more thorough example I would recommend you check out the example in our Macro Library called "Create pack and go with specified custom property as prefix".
Thank you Keith
Your code is very usefull, it is close to what I need.
Using PackAndGo I succeeded in copying a file with its drawing (and components if it is an seembly)
I used "SetSaveToName" and it worked properly.
The only problem is that I wished to rename my new files, and I did not manage to use "SetDocumentSaveToNames" properly. I think I followed your code properly, but I keep on getting the answer "File already exists".
So what I do now is a "save as" of each created file, then change their references, then delete all files created by PackAndGo.
It works for Part files, I have to try it for Assembly files now. The code will be much longer than expected, but unfornately PackAndGo seems a little bit tricky to use...
Good help anyway, thank you.