vlaxcreateobject
vlax-create-object is a Visual LISP function used to create a COM (ActiveX) automation object from a programmatic identifier (ProgID) or CLSID. It enables AutoCAD and other VLisp environments to automate external Windows applications and components that expose COM interfaces, such as Microsoft Office applications or custom automation servers. The object returned is a COM wrapper that can be manipulated with VLisp’s automation helpers.
The typical usage is (vlax-create-object progid [server]). The progid is a string that identifies the COM class
The returned object is a COM automation object (vlax-ole-object). You interact with it through vlax helper functions
(setq xl (vlax-create-object "Excel.Application"))
(vlax-put-property xl 'Visible :t)
(setq wb (vlax-invoke-method (vlax-get-property xl 'Workbooks) 'Add))
; perform operations on the workbook
- The target ProgID must be registered on the system; otherwise the call fails.
- COM automation depends on the bitness and permissions of the host and target applications; ensure compatibility
- Use vlax-release-object when the automation object is no longer needed to free resources.
Related functions include vlax-get-property, vlax-put-property, and vlax-invoke-method, which are used to read, set, and call methods