Problem description: Add method of Styles class failed
Upon exporting some Dynamics AX data to Microsoft Excel, I ran into an Error, mentioning the cryptic Add method of Styles class failed.
Solution: Rename the added Style
I described in a previous post Export to Excel with X++ code: the sequel, how formatting can be added to the exported AX data in Excel by using the Styles class. This error message occurs when the collection object of the same class and name already exists, and you attempt to add it a second time with the same name. So apparently I had already a Style in my Microsoft Excel file with the same name as I was adding through my X++ code. I changed the name of my added Styles in my X++ code an my export went fine afterwards.
Post a Comment