I'm trying to automate the drawing-creation in our company. Steps I've taken:
- create new drawingdocument with template
- Save new drawingdocument
Problem:
Creation of new document works, but the next step, saving it to a specific location, fails. Error handler is initiated and displays error: Invalid procedure call or argument.
Used code:
Dim DXF_DWG as DrawingDocument 'Create new drawing based on template Set DXF_DWG = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, ThisApplication.FileOptions.TemplatesPath & "\Folded and Flatpattern DXF.dwg", True)
'Save new drawing to specific location Call DXF_DWG.SaveAs("C:\Temp\Test.dwg", False)
As told, the VB-code raises an error on the last command. What am I doing wrong? What are the correct steps in VBA to create a new drawing document based on a template and save the newly created drawing to a desired location?
Solved! Go to Solution.
Solved by miechh. Go to Solution.
Your code is correct and works fine with my templates.
Can you upload your Folded and Flatpattern DXF.dwg ?
Vladimir,
Thanks for your response. You said my code was correct, that's good for my confidence! . I just found out what may have caused the problem. There was some VBA-code in the template (triggered on Save event). The template is a copy of another template in which a dialog will pop up asking the user in what state the drawing is (preliminary, final, etc.) when saving the drawing. This code was still present in the dxf-dwg template, and probably caused the problem. I removed the VB-code in the template and now it's working fine. Only thing I've come across is the dialog window showing up during the SaveAs command; asking me to save the dependant files. Still have to click on "yes to all" and "OK".
I suspected something similar to this.
My congratulations!