Hi Kalyan,
yes and no, it all depends.
Sorry, these are too many questions for me right now.
So a bit of theory might help you more than just some code lines.
Whith the code I posted you get a page,
in a very simplified way.
Word doesn't really know much about pages.
Pages are recalculated on the fly,
depending on the printer and other variables.
If you do something to a page,
like deleting the last word,
the first Word from the next page
might move to the actual page.
Ok, if it has to be,
this replaces all text in brackets
on page 25, as it was when the macro started,
with some other text.
But note, that text in brackets may move from the
next page to the actual page and
complicate things a lot.
Split it all up in seperate questions and ask again.
Some other people might know as well,
and some might even know better.
Sub Test67()
Dim lPages As Long
Dim rTmp As Range
lPages = ActiveDocument.ComputeStatistics(wdStatisticPages)
ActiveDocument.Range(0, 0).Select
Selection.ExtendMode = False
Selection.GoTo _
what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=25
Set rTmp = Selection.Bookmarks("\page").Range
With rTmp.Find
.Text = "\[*\]" ' any text between brackets
.Replacement.Text = "[this was deleted]"
.Wrap = wdFindStop
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Selection.Collapse
End Sub
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
kalyan - 27 Nov 2007 14:18 GMT
am using the following code to remove bulleted text
Dim rngTarget As Word.Range
Dim oPara As Word.Paragraph
Set rngTarget = Selection.Range
With rngTarget
Call .Collapse(wdCollapseEnd)
.End = ActiveDocument.Range.End
For Each oPara In .Paragraphs
If oPara.Range.ListFormat.ListType = WdListType.wdListBullet
Then
oPara.Range.Select
Selection.Delete Unit:=wdCharacter, Count:=1
End If
Next
End With
this code works as follows
input
-----------
* Diagnostic hearing exams.
* [Routine Hearing tests]
* [Fitting and evaluation for hearing aids]
* [Hearing aids]
output
-----------
* Diagnostic hearing exams.
* [Routine Hearing tests]
* [Fitting and evaluation for hearing aids]
*
the problem occurs only if the bulleted text is the last one in the
list
any ideas to how to modify the code so that..even the last bullet
along with the text is removed
Thanks & Regards
Kalyan
> Hi Kalyan,
>
[quoted text clipped - 54 lines]
>
> Vista Small Business, Office XP
Helmut Weber - 27 Nov 2007 15:35 GMT
Hi Kalyan,
>input
>-----------
[quoted text clipped - 9 lines]
>* [Fitting and evaluation for hearing aids]
>*
I can't reproduce the behaviour you've described.
Though your code looks a bit odd to me,
but of course everybody is used to his own style,
it is working perfectly, it seems.
Sorry.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
fumei - 27 Nov 2007 17:53 GMT
The code looks a little odd to me as well.
The last paragraph is bulleted because the code removes the text, but does
not change the style. Change the style.
kalyan - 29 Nov 2007 13:07 GMT
Actually if i modify my code as follows
Dim rngTarget As Word.Range
Dim oPara As Word.Paragraph
Set rngTarget = Selection.Range
With rngTarget
Call .Collapse(wdCollapseEnd)
.End = ActiveDocument.Range.End
For Each oPara In .Paragraphs
If oPara.Range.ListFormat.ListType = WdListType.wdListBullet
Then
If oPara.Range.Text="Hearing aids" then
oPara.Range.Select
Selection.Delete Unit:=wdCharacter, Count:=1
End if
End If
Next
End With
then i get the output as follows
output
-----------
* Diagnostic hearing exams.
* [Routine Hearing tests]
* [Fitting and evaluation for hearing aids]
*
now how 2 handle this case??
> The code looks a little odd to me as well.
>
[quoted text clipped - 3 lines]
> --
> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/word-programming/200711/1