How to use document.importStylesFromJson to import a style with space or dash in the name.
I'm attempting to use the document.importStylesFromJson(jsonstring)
method to create styles in an existing document. I've figure out that for each style in the jsonstring, a nameLocal
object needs to be specified as the name of the style. However, this name seems to be more restrictive than the name that can be provided using the Word GUI. As an example, if nameLocal
is given a string with spaces or dashes (underscores work!), the method fails to create the desired style in the document.
As an example, the following json string will produce a style in the document named teststyle3
, but will completely ignore the creation of teststyle 4
.
{"teststyle3":{"baseStyle":"Default Paragraph Font", "quickStyle":true,"nameLocal":"teststyle3", "priority":4, "type":"Character", "font":{"bold":false, "color":"#00ff00"}}, "teststyle4":{"baseStyle":"Default Paragraph Font", "quickStyle":true, "priority":4, "nameLocal":"teststyle 4", "type":"Character", "font":{"bold":false, "color":"#00ff00"}}}
If I remove the space from "nameLocal":"teststyle 4",
then a style named teststyle4
will also be produced.
Is there any way to specify style names with spaces or dashes? Is there a more complete set of documentation about document.importStylesFromJson()
available?
Thanks!
David Chrudimsky