Hi @Anonymous. I assume you are trying to create a VBA macro with this code, right?
Well, the term 'ThisDoc' is not recognized in VBA, because it is defined within the iLogic add-in, for one thing, plus I don't think you even need to retrieve a currently open assembly document, if you are simply trying to create a new part file from its template. Another point about VBA is that you don't need to use the 'Set' term in front of a line that is setting the value of a String (or a Double, Integer, or other simple data types), but you do for other types of variables.
Try this version. I tested this on my own system (with a different file name) and it works for me.
Sub StartNewPieceShopPart()
Dim oApp As Inventor.Application
Set oApp = ThisApplication
oTemplatesPath = oApp.DesignProjectManager.ActiveDesignProject.TemplatesPath
oTemplateFile = "piece SHOP.ipt"
oTemplate = oTemplatesPath & "\" & oTemplateFile
Dim oPartDoc As PartDocument
Set oPartDoc = oApp.Documents.Add(kPartDocumentObject, oTemplate)
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)