Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
C-Hoppen
in reply to: C-Hoppen

I tried to do it with VBA but same problem.

I noticed that there is a difference in the signature of CopyTo between VBA and the API doc.

 

API

ReplaceExisting: Optional input Boolean that specifies whether replace the existing asset if an asset of the same name exists.

 

VBA

CopyTo.jpg

So I tried this

Dim docMaterial As MaterialAsset
Set docMaterial = ThisDocument.ActiveMaterial

Dim libMaterial As MaterialAsset
Set libMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(docMaterial.DisplayName)

Set docMaterial = libMaterial.CopyTo(ThisDocument.MaterialAssets, docMaterial)

 

and this

Dim docMaterial As asset // <-- why does this always turn to lower case?
Set docMaterial = ThisDocument.ActiveMaterial

Dim libMaterial As asset
Set libMaterial = ThisApplication.ActiveMaterialLibrary.MaterialAssets.Item(docMaterial.DisplayName)

Set docMaterial = libMaterial.CopyTo(ThisDocument.Assets, docMaterial)


and this (as desribed in the API docs)

Set docMaterial = libMaterial.CopyTo(ThisDocument.Assets, True)


and it always chrashes at CopyTo.

 

How can I update a existing MaterialAsset from a library?

 

Thanks,

Christoph