I'm trying to save by code (CATVBA macro) a Part as a new Part document. I do not want to use the SaveAs method since I do not want to modify the current product structure, so I create a new PartDocument and I try to copy the previous Part content I want into the new one. Here is what I have so far:
Public Sub CopyFromDocToDoc(iMainDoc As Document, iFromPart As Part, iToPartDoc As PartDocument)
Dim i As Integer
Dim sel As Selection: Set sel = iMainDoc.Selection
For i = 1 To iFromPart.HybridBodies.Count
iToPartDoc.Part.InWorkObject = iFromPart.MainBody
The issue is when getting to the "sel.Copy" line, I have an error: "Method 'Copy' of object 'Selection' failed".
The error is not very explicit enough to point out the issue...
Does anyone has an idea of the problem here ?