Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Copying a style object to make a new one

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Garry - 28 Nov 2005 23:55 GMT
Hi All:

I'm missing something obvious.

I want to create a new style by copying an existing one and making a
few mods, the equivalent to using the "Based On" field in the styles
dialog. After thinking about Set statements and the like, I'm confused
as to how to go about this. Just how does one copy an object?

Garry
Greg Maxey - 29 Nov 2005 01:05 GMT
Something like:

Sub Scratch()
Dim style As Style
Set style = Active.Styles.Add("YourNewStyleName")
With oStyle
 .BaseStyle = ActiveDocument.Styles("Normal")
 .Font.Bold = True
 .ParagraphFormat.LineSpacing = 24
End With
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi All:
>
[quoted text clipped - 6 lines]
>
> Garry
Klaus Linke - 29 Nov 2005 01:14 GMT
Hi Garry,

There's no "clean" way in VBA to copy a style, AFAIK. You just use .Add to
create a new one, and set ".BasedOn" to the existing one.
As in the user interface, the newly added style will pick up any manual
(font/paragraph) formatting from the start of the current selection, so
you'd either need to make sure that none is applied, or (re)set all the
formatting to that of the  base style.

Regards,
Klaus

> Hi All:
>
[quoted text clipped - 6 lines]
>
> Garry

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.