Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-27-2022, 09:31 AM
ILauder ILauder is offline How to set a docs Default Paragraph settings via VBA Windows 11 How to set a docs Default Paragraph settings via VBA Office 2021
Novice
How to set a docs Default Paragraph settings via VBA
 
Join Date: Oct 2022
Posts: 2
ILauder is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 10-27-2022, 02:31 PM
macropod's Avatar
macropod macropod is offline How to set a docs Default Paragraph settings via VBA Windows 10 How to set a docs Default Paragraph settings via VBA Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 10-27-2022, 03:46 PM
ILauder ILauder is offline How to set a docs Default Paragraph settings via VBA Windows 11 How to set a docs Default Paragraph settings via VBA Office 2021
Novice
How to set a docs Default Paragraph settings via VBA
 
Join Date: Oct 2022
Posts: 2
ILauder is on a distinguished road
Default

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....
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set a docs Default Paragraph settings via VBA 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
How to set a docs Default Paragraph settings via VBA 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft