-
-
Notifications
You must be signed in to change notification settings - Fork 34
Will you be adding support for styles? #10
Comments
What you mean by Styles? |
https://msdn.microsoft.com/en-us/vba/word-vba/articles/style-object-word?f=255&MSPPError=-2147217396 Paragraph and character styles. Either have access to apply a existing style to a paragraph or create a new style. |
Those are already there as far as I know. Unless you mean something completely different you can already set color, font size, heading1-9, and so on. Tables can have design. Not sure if you want something else? |
Yes, something different. I am a technical writer. The standard practice for Microsoft Word is to define a set of style first, then use those styles for every paragraph. It's like the same idea as separation of concerns in web design. Instead of formatting the text with inline formatting, you would have a define CSS sheet for the fonts and colors of the items. H1-H9 are builtin styles. It would be good to be able to define new styles and also be able to change the appearance of H1-H9. So I think I am looking for something like:``` Add-WordParagraphStyle -WordDocument $WordDocument -Name 'LabelText' -FontSize 24 -Color Red -Bold $true
|
Well there are 2 ways to do it.
I can see this...
Which is being utilized by Heading1-9. I believe if you would create "styles" in template with this property we could utilize it. However I am not sure how to set it to proper style if you would like to build it from scratch.
The problem with that it won't be available outside of PSWriteWord. So if you want to continue using same style in Word after generation ... it won't be there. It will require some work to implement but this could be done for "custom table styles" and any other things. But the ultimate problem with it .. behind the scenes I will be building this "manually". I won't be saving this as a style in Word. |
The Short Way is not really that great. After all, most of the time, you generate a DOCX file because you intend for it to be edited by other people. If I don't want others to edit or change it, I would send a PDF. But, this short way is still very useful in a pinch. The Long Way is what I wanted. |
To be honest I've not tested any of it. Heading1-9 works as it's defined that way. I would need to do some testing with it. Maybe I will have some time during weekend. Currently I'm rewritting Add-WordTable to be consistent with what $Variable | Format-Table outputs. Right now Add-WordTable does conversions but this will change. It will not do conversion. It will deliver the same output that Format-Table does (well similar at least. But to still provide functionality of conversion (kind of pivot rows names with column names) I will deliver switch do to that. |
Doing table are just horrible in Word -- programmatically or otherwise. This is a great thing and great project. |
New version (on github), not yet released to PS Gallery changes things a bit and affects how Add-WordTable works. It will now work in a way where you can expect $data | Format-Table to be identical in word. So if you have hashtable or ordinarydictionary you need to use -Transpose switch. There is also external command that can do that "change" before applying it to Word. |
Actually, I'm creating documents from a template with all Styles for differents sections... It would be nice to be able to, at least, use existing styles when adding text... not really needs to create them in my case. |
I am working on a new project which will be a total rewrite (not only on PowerShell level) but also on .NET level meaning PSWriteWord will be archived and the new project will take over. I will have full control over the .NET code so a lot of different options will be possible. It will have much larger options. I did a sneak peak on Twitter - https://twitter.com/PrzemyslawKlys/status/1496576889250582533 |
Is support for styles on the roadmap?
The text was updated successfully, but these errors were encountered: