问题
Excel workbooks have a CustomDocumentProperties
collection. This collection is of type DocumentProperties
and has an Add
method that I'm attempting to call from MATLAB.
If I call the invoke
method on the collection I see:
>> workbook.CustomDocumentProperties.invoke
Item = handle Item(handle, Variant, int32)
Add = handle Add(handle, string, bool, int32, Variant(Optional))
I assume this means the Add
method requires a string, boolean, int32
, and an optional variant, and this matches with the Microsoft documentation for the Add
method.
However, all combination of inputs I've tried to this function result in an error. For example:
workbook.CustomDocumentProperties.Add('MyProp', true, int32(1), true);
Results in the error:
Invoke Error: Incorrect number of arguments
If I supply 7 or more arguments then I get the error:
Error: Invalid number is arguments. This method can take maximum 6 arguments
If I supply anything other than a string as the first argument I get the error:
No method 'Add' with matching signature found for class 'Interface.2DF8D04D_5BFA_101B_BDE5_00AA0044DE52'.
Has anyone successfully used this function to add a custom property to an Excel workbook from MATLAB?
来源:https://stackoverflow.com/questions/21688934/unable-to-add-custom-properties-to-an-excel-workbook