vba - How to add a DocumentProperty to CustomDocumentProperties in Excel? -
i'm trying add together documentproperty customdocumentproperties collection. code follows:
sub testcustdocprop() dim docprops documentproperties dim docprop documentproperty set docprops = thisworkbook.customdocumentproperties set docprop = docprops.add(name:="test", linktocontent:=false, value:="xyz") end sub
running gives me next error:
run-time error '5': invalid procedure phone call or argument
i tried running .add
void function, so:
docprops.add name:="test", linktocontent:=false, value:="xyz"
this gave me same error. how add together custom document property?
try routine:
public sub subupdatecustomdocumentproperty(strpropertyname string, _ varvalue variant, doctype office.msodocproperties) on error resume next wb.customdocumentproperties(strpropertyname).value _ = varvalue if err.number > 0 wb.customdocumentproperties.add _ name:=strpropertyname, _ linktocontent:=false, _ type:=doctype, _ value:=varvalue end if end sub
vba excel-vba
No comments:
Post a Comment