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 2007

Tip: Looking for answers? Try searching our database.

Adding Style Word 2007 problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KAM - 13 Nov 2007 16:14 GMT
I am trying to add styles to a document through vba code. (I am only doing it
this way since .Organizercopy in vba requires the destination doc to be saved
local first...which I still don't have a work around.)

In vba, I have created "_Journal font" style to be my "base" style. All
attributes are defined explicitly in code.

Then I add another style (in vba):
Application.ActiveDocument.Styles.Add Name:="_Document", _
Type:=wdStyleTypeParagraphOnly
   With ActiveDocument.Styles("_Document")
       .AutomaticallyUpdate = False
       .BaseStyle = "_Journal font"
       .NextParagraphStyle = "_Document"
   End With
   With ActiveDocument.Styles("_Document").ParagraphFormat
       .SpaceAfter = 10
       .LineSpacingRule = wdLineSpaceSingle
       .FirstLineIndent = InchesToPoints(0.25)
   End With

And I have only coded for those attributes that are different from the base
style "_Journal font".

Stepping through the code, I have to add it first (which adds the new style
_Document and bases it on Normal. Then when it runs the code to base it on
"_Journal font" it SAYS it is based on "_Journal font" but it still is
retaining the formatting from Normal.

It seems like useless code to add ALL of the attributes for each and every
style that I am adding - especially since they are based on another style and
may just have one small change.

Oh please HELP!
Thanks!
KAM - 13 Nov 2007 16:22 GMT
This just got stranger...the newly created style is actually taking on the
attributes of the paragraph where the cursor happens to be sitting when the
code is run.

My first paragraph in the doc is Normal + 14 pt
When the new style adds, it does not take the font size from MY defined base
style, it keeps the 14 pt from where my cursor is sitting....

I don't even know how to explain this. Help.

> I am trying to add styles to a document through vba code. (I am only doing it
> this way since .Organizercopy in vba requires the destination doc to be saved
[quoted text clipped - 31 lines]
> Oh please HELP!
> Thanks!
 
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.