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 / October 2007

Tip: Looking for answers? Try searching our database.

Copy only specific styles with VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kurt - 01 Oct 2007 15:25 GMT
Is there a way to copy JUST a select set of styles from a template with VBA
(not Word's Organizer) to another document, rather than all of Word's
undeletable built in styles?

Thanks much!

Kurt
Jean-Guy Marcil - 01 Oct 2007 16:10 GMT
kurt was telling us:
kurt nous racontait que :

> Is there a way to copy JUST a select set of styles from a template
> with VBA (not Word's Organizer) to another document, rather than all
> of Word's undeletable built in styles?

An easy work around is to create one paragraph per style and assign a
different style to each paragraph. Transfer those paragraphs to the target
document and then delete the paragraphs.
The fact that the paragraphs formatted with new styles were present for a
split second is enough to add the style to the target document style list.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Russ - 01 Oct 2007 19:03 GMT
Kurt,

Did you know that you can use the Organizer **through VBA** to copy styles
(and do its other functions)?
Code below is one line:
   Application.OrganizerCopy Source:=MyTemplatePath & _
       "MyTemplate.dot", Destination:= _
       MyAppDataPath & "\Microsoft User Data:Normal", Name:= _
       "MyStyle", Object:=wdOrganizerObjectStyles

> Is there a way to copy JUST a select set of styles from a template with VBA
> (not Word's Organizer) to another document, rather than all of Word's
[quoted text clipped - 3 lines]
>
> Kurt

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Russ - 02 Oct 2007 06:58 GMT
Kurt,
In case you're wondering how I got the VBA code.
I recorded a macro while manually using the Organizer.
You can make the output more useful by trimming unnecessary lines and by
strategically placing variables where they add versatility.

> Kurt,
>
[quoted text clipped - 13 lines]
>>
>> Kurt

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
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.