Help me out with bullet styles

S

sorcerer

Hi to all.
Am a new member.
I am working on a macro for Changing the bullet styles in my document
from bullet 3 to bullet style 1 whenever i come across bullet style 3.
Do anyone of you know how to do it.

Vijay
 
H

Helmut Weber

Hi Vijay,
Am a new member.

and already confronted with one of the most
difficult and most unreliable features of Word.

I couldn't find out a way to get information,
about what listgallery template was applied to
a paragraph. Except some awful theoretical
workarounds as discussed in this thread,
above all by "Wordheretic" Steve Hudson and Klaus Linke.

http://groups.google.com/groups?
hl=de&lr=&threadm=Oke3hMnFDHA.336%
40tk2msftngp13.phx.gbl&rnum=16&prev=/groups%3Fq%
3Dlisttemplate.name%2Bgroup:microsoft.public.*%26hl%3Dde%
26lr%3D%26scoring%3Dd%26start%3D10%26sa%3DN
' ---- or
http://tinyurl.com/45qeq


But it must be possible to identify the
listparagraphs in question by some other properties
like indentation, font, style, tabs, liststring
or others.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
K

Klaus Linke

Hi Vijay,

If that are paragraph styles you are talking about, you can use "Find/Replace" to find ""bullet 3" paragraphs and replace with "bullet 1" style (leaving "Find what" and "Replace with" empty).
If that wasn't what you meant, post back.

Regards,
Klaus


----- Original Message -----
From: "sorcerer" <[email protected]>
Newsgroups: microsoft.public.word.vba.general
Sent: Thursday, March 10, 2005 10:53 AM
Subject: Help me out with bullet styles
 
S

sorcerer

Hi Helmut Weber.
I already found out listparagaphs. Thats not a problem
I am specifically looking out for bulleted lists, that too the square
bullets,
in order to change them to round bullets.
 
S

sorcerer

No Klaus.
That doesn't work.
Unless word has some specific character to search it does not search
and replace.
I wanted it to search for bulleted lists, which i guess one will have
to manually
hard code it.
 
S

sorcerer

Hi Helmut Weber.
I already found out listparagaphs. Thats not a problem
I am specifically looking out for bulleted lists, that too the square
bullets,
in order to change them to round bullets.
 
H

Helmut Weber

Hi Vijay,

how about this one:

Dim oPrg As Object
Dim cNum As Long
Dim cFNt As String
For Each oPrg In ActiveDocument.ListParagraphs
cNum = AscW(oPrg.Range.ListFormat.ListString) + 4096
cFNt = oPrg.Range.ListFormat.ListTemplate.ListLevels
(1).Font.Name
If cNum = 167 And cFNt = "Wingdings" Then
oPrg.Range.Select ' for testing
MsgBox "Found listparagraph with square bullet"
' or do some other stuff
End If
Next
End Sub

It is assumed, that the paragraph in
question is in listlevel 1 and that
the bullet is from Wingdings etc.

Beware of linebreakes by the newsreader.

I think, applying a new listtemplate
won't be much of a problem.


Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
S

sorcerer

You're a genius Helmut Weber.
Thank you. Will approach you for further clarifications if you don't
mind it.
and hey I din't quite understand the logic behind
"cNum=AscW(oPrg.Range.ListFormat.Lis­tString) + 4096"
Can you clarify. Hey hope I am not disturbing you.
 
H

Helmut Weber

Hi Vijay,
Thank you. Will approach you for further clarifications if you don't
mind it. welcome,

and hey I din't quite understand the logic behind
"cNum=AscW(oPrg.Range.ListFormat.ListString) + 4096"
Can you clarify. Hey hope I am not disturbing you.

I don't know why Word returns a negative number for
AscW(oPrg.Range.ListFormat.ListString)
Maybe Klaus can explain.
It's just that the asc-value is Dec 4096 (Hex 1000) away.

I have some vague ideas, but they might ruin all reputation,
if I make them public.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
S

sorcerer

Hi Helmut.
Hey one doubt.
Just like you searched for the square bullet.
Is there a way to search for bullets like
1.
2.
3.
and change them to
1
2
3
(See the dots are not there)
Just try this one for me Helmut.
 
H

Helmut Weber

Hi Vijay,

you could redefine the listtemplate 1
and apply it to each listparagraph that meets
the conditions. Whereby _each listparagraph_ is
overdoing it, as _each list_ would be sufficient.

But I admit, I have no idea, how to address a list.
And, whether the definition of conditions is alright,
depends of all other listtemplates. It's hell.

I don't use listgalleries at all. Too complicated.
I'm working with very small, very simple documents.
The challenge there is that there number is greater than 350,000.

Dim oPrg As Object
Dim sLst As String
With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1"
End With

For Each oPrg In ActiveDocument.ListParagraphs
sLst = oPrg.Range.ListFormat.ListString
If Right(sLst, 1) = "." Then
If IsNumeric(Left(sLst, Len(sLst) - 1)) Then
oPrg.Range.ListFormat.ApplyListTemplate _
ListTemplate:=ListGalleries( _
wdNumberGallery).ListTemplates(1)
End If
End If
Next
 
S

sorcerer

Hey Helmut.
Wish I knew macros the way you know it.
Thats a good code and it works very well.
Hey any books you can suggest that I could go through.
And hey do macros have good command in software markets around the
world.
I mean its hardcore development isn't it.
 
H

Helmut Weber

Hi Vijay

see
http://www.google.de/groups?hl=de&l..._ugroup=microsoft.public.word.vba.*&lr=&hl=de

or

http://tinyurl.com/63e3y

I don't read books anymore, in a way. ;-)
I try to solve a problem or to realize a project
and search dozens of books for help by checking the
tables of contents, the indices, reading this and that
in a rather unsystematic way.
do macros have good command in software markets around the world.
I mean its hardcore development isn't it.

As a native speaker of german i am not quite sure what you mean.
A macro can be 3 lines long or 3000 lines long.
It is just programming, whether you call the code a macro
or a function or anything else. Some people can make a living
by VBA (Macro) programming. Hardcore development? I wouldn't say so.
VBA programming seems to me to work on the surface of office
applications. I wouldn't say I have knowledge in depth.
Maybe hardcore development starts with C and ends with
assembler. If the art of assembler programming is still
existing at all.

Have a nice day.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
S

sorcerer

Hi Helmut.
I have a problem with the code that you gave me.
The functioning is fine, but hey when i try to give a tab position to
the numbered lists.
only the last element gets it. The first two elements remain the same
in their place.

Hey one more doubt that I have is this: In a document I have three
sorts of lists.
which i have to indent in three different ways. I am having serious
trouble in doing that.
Can you please help me with this problem.
 
H

Helmut Weber

Hi Vijay,
where do you define the tab postition?

If you define it in the listtemplate and
apply the template to the whole list,
ApplyTo:=wdListApplyToWholeList
then it should work.

With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1"
.TextPosition = CentimetersToPoints(1)
.TabPosition = CentimetersToPoints(1)
End With
' selection or range in question
Selection.Range.ListFormat.ApplyListTemplate _
ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(1), _
ApplyTo:=wdListApplyToWholeList

But, there must be sufficient space for Word to place the tabs.
.TextPosition = CentimetersToPoints(1)
.TabPosition = CentimetersToPoints(1)
results in a mess, whereas
.TextPosition = CentimetersToPoints(2)
.TabPosition = CentimetersToPoints(2)
adjusts the text neatly.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
S

sorcerer

Hi Helmut.
Hey the tab position is fine.
I was talking about the indentation from the margin.
Is there any way to adjust that according to the list that we are
dealing with.
I mean is it possible to find out the current indent of any list.
Because I wanted to give different indentations to different lists
like 0 left for Outline numbered, 0.79 for bulleted etc..
 
K

Klaus Linke

No Klaus.
That doesn't work.
Unless word has some specific character to search it does not
search and replace.

You can search for any formatting and replace with another formatting (style, bold, whatever).
No need to search for specific text.
I wanted it to search for bulleted lists, which i guess one will have
to manually hard code it.

If those bulleted lists were formatted with styles, it wouldn't have been a problem to redefine the style or replace it with another style.

Greetings,
Klaus
 
H

Helmut Weber

Hi Vijay,

no time for an explanantion in all details, sorry.

MsgBox Selection.Paragraphs(1).TabStops(1).Position
MsgBox Selection.Paragraphs(1).LeftIndent

Most often there will be the same, though
fractions like 36 vs. 35.45 points seem to occur.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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