#1
|
|||
|
|||
How to set a docs Default Paragraph settings via VBA
How do you set the default paragraph format settings for Space Before, Space After, Line Spacing Rule for the defaults used for the active document?
I know how to set these for individual paragraph selections and paragraph font styles but I can't find where to set the defaults for the whole document. I've tried recording a macro and making the settings in the UI but the macro doesn't record it. The UI screen I'm referring to is open a Word document. Click Styles icon, click the Manage Styles button (the A w/ checkmark), click the Set Defaults tab. And I want to set the Before:, After: and Line Spacing: settings via VBA. I also tried setting the SpaceBefore, SpaceAfter, LineSpacingRule for the built in Word style "Default Paragraph Font" but in VBA that just returns an error that you can't set those for a character style. I need to change these in a newly created document created in VBA to copy/paste the contents of another file. But the original file's default paragraph settings are different. And Word's VBA functions for PasteAndFormat(wdFormatOriginalFormatting) doesn't retain the original formatting of the source paragraphs when they are text that is inside of text objects. Its picking up the defaults for the new document. So I need to change those to match before pasting in the content. Many thx if someone knows where to set this. |
#2
|
||||
|
||||
Instead of trying to do this with direct formatting, you should be modifying the underlying Styles. If you make those changes to a document template, they'll automatically apply to all new documents based on that template. Furthermore, having made those changes to the document template, all you'd need do to apply them to current documents is to check the 'Automatically update document styles' property in each of the applicable documents. No VBA code needed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks but I got it figured out. You can't set those via VBA, and it turned out I just need to update the Normal style settings in the new document. And yes, it does all have to be done via VBA as it is part of a document assembly software system and I'm needing to write a workaround for a bug MSFT introduced in their Aug build that is causing InsertFile to fail to insert documents that has been working on a library of templates that has worked for about 20 years now. So this is for a VBA repair tool to rebuild the documents using copy/paste vs InsertFile. Long story....
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tab settings not translating to pasted docs | jbeau | Word | 2 | 04-28-2017 01:01 PM |
Default settings - HELP | Louise1987 | Word | 2 | 05-24-2016 11:05 PM |
File name and Doc settings are printing and appending to my Word docs. | wranglerman4you | Word | 4 | 12-30-2013 12:45 AM |
Default settings don't stay when default language changes | Nathan | Word | 1 | 10-21-2013 03:59 AM |
Recent docs settings changed | Jennifer Murphy | Word | 2 | 05-20-2012 06:21 AM |