same style but with different name

A

Associates

Hi,

I have an issue with style and formatting in word template. In the template,
i have set a style (outlined number) called "Section Heading 1". Then, i have
created an autotext which has the same style with the same name. So when i
insert the autotext into the template, i got 2 of the same style with
different names. The style got inserted into the template has its name
changed to "Section Heading 1 + justified".

The following code i use to insert the autotext
ActiveDocument.AttachedTemplate.AutoTextEntries("sections").Insert Where:= _
Selection.Range, RichText:=True

My question is how do i keep it to the same style name because at the end of
the day, there should be only one style called "Section Heading 1". I think
word adds "+ justified" at the end of "Section Heading 1" because "Section
Heading 1" already exists. Is there any way of stopping this for word 03?

Thank you in advance
 
G

Gordon Bentley-Mix

I am unable to replicate the behaviour you have described. However, I believe
that the source of the problem may be as follows:

When you created your AutoText entry you applied direct formatting
(justification) to the paragraph using your 'Section Heading 1' style. Then,
after inserting this AutoText entry into your document, have mistaken the
information shown in the 'Style' dropdown on the Formatting toolbar (and/or
the 'Styles and Formatting' Task Pane) as indicative of the creation of a new
style.

All that "+ justified" means is that the justification has been added to the
style as some point in the document; it has nothing to do with the insertion
of AutoText - either through code or native Word processes. The exact same
thing happens if you apply any (non-justified) style to a paragraph and use
direct formatting to justify the paragraph. In reality, no new style has been
added, and if you delete the content added through the AutoText entry (or
simply remove the justification from the paragraph from the AT entry that
uses the 'Section Heading 1' style), you may find that your 'Section Heading
1 + justified' "style" is gone. In addition, if you display the 'Styles and
Formatting' Task Pane and select "Available styles" in the 'Show:' field, you
probably will not find this 'Section Heading 1 + justified' "style" -
although it may still be displayed in both the 'Formatting of selected text'
box and the 'Style' dropdown on the Formatting toolbar.

I suggest that you take some time to broaden your understanding of Word if
you intend on continuing to post in this forum. (And in relation to this
"issue" you might want to explore the 'Reveal Formatting' Task Pane.) By my
count this is the fourth post of yours that I have responded to, and in each
case I have found myself having to explain some very basic Word concepts in
my answers. In addition, you provide no feedback on whether the answer has
resolved your issue or not. Accordingly, I have resolved to no longer respond
to your posts. I'm always happy to help - but only those who are willing to
help themselves and show their appreciation for the assistance they do
receive.
--
Gordon
~waiting to get booted out of the forum~

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Graham Mayor

Uncheck tools > options > edit > keep track of formatting?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jean-Guy Marcil

:

I'm always happy to help - but only those who are willing to
help themselves and show their appreciation for the assistance they do
receive.

It does make the "helping" more enjoyable...

Sometimes those who are using the Web interface do come back and while they
do not actively write a response to show their appreciation, they do click
"Yes" for either "Did this post answer your question?" or "Was this post
helpful to you?"
This appreciation is only visible with the Web interface.

So, if you do not use the Web interface, you may not be aware a poster has
in fact acknowledged a reply...
 
G

Gordon Bentley-Mix

Good thought, Jean-Guy, but no. No green checkmarks. No replies. Nothing.
Like pouring info down a black hole...

Oh well. Live and learn. Nobody's forcing me to share my knowledge. Guess I
just need to be a bit more discerning about how and where I put my hand in.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Gordon Bentley-Mix

AHA! This explains why I was seeing "+ justified" on my own computer but not
on the one I'm using at my client site...
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
A

Associates

Hi Graham,

Thank you for your reply and sorry for taking too long to get back to you.

Yes, your suggestion did get rid of the "+justified". There is now only
"Section Heading 1" style in the styles and formatting list. However, what
has not worked yet is that when the "insert section" sub (the code is shown
below) is invoked, it should bring up "Section 2" as "Section 1" is already
there generated by the autotexts but it still generates "Section 1". It
appears to me that they are not using the same style. I mean if they are, we
should then get "Section 2" since "Section 1" already exists in the first
place. I have been thinking of any fixes but couldn't come up with anything.

Here is the code
Sub InsertSection()
' Insert a heading for the new section.
Selection.Style = ActiveDocument.Styles("Section Heading 1")

Selection.TypeText Text:=InputBox("Please enter section heading:")
Selection.TypeParagraph

' Add another one paragraph gap before typing begins.
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage

Call UpdateTOC

End Sub

Thank you in advance
 
A

Associates

Hi Gordon,

Thank you for all of your replies and apologise for being slow in replying
to them.

I did read your last three replies and did not have the opportunity to try
out your suggestions as other important things arose along the way. So i have
been putting those issues aside in the hope that i could come back and look
into those problems later. I'm aware that my knowledge of word isn't that
great but am learning my way around it. All the posts i sent, i do try myself
really hard to some extend that i really need help from other experts like
yourself. I tried to look for VBA programming book for word document but so
far with no luck yet.

So just to let you know that i do greatly appreciate your replies very much
because i noticed you have been very helpful for the last 4 threads i posted.

Thank you once again
 
A

Associates

Hi Graham,

it works now. The problem is that i chose the wrong style during the process
of adding to the autotexts. Please disregard the earlier post i sent today.

Thanks once again for your help.
 
G

Gordon Bentley-Mix

Apology accepted. I understand how busy life can be. But please do take a bit
of time to increase your understanding of some of the basics of Word. It will
benefit you greatly in that when you do post a query, you will be better able
to understand the answer. (Plus you won't get "flamed" or ignored, which
would be the ultimate barrier to getting help.)

As for a VBA programming book, they _are_ rather difficult to find, but I
found "Writing Word Macros" by Steven Roman helpful when I first started
(although others would probably disagree). However, most of my knowledge has
been gained from the VBA help and just basic trial-and-error. What I feel has
been the most beneficial to me is coming to grips with the way Word works -
because pretty much anything Word can do natively can be done through code.
Of course, quite a few things Word does better and more easily than can be
achieved through VBA...

I guess my recommendation to you would be to first find a good source on
Word itself and then use this as the basis for developing your programming
skills.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top