Criteria Search - Final Solution

A

Aaron

Hi Helmut,

Sorry so long to get back. Running the whole show can
get busy. I still am hazy on how the information works
and what 10 is for. In the help file I kind of
understand what is going on.. but did
not find any 10.

Thank you so very much for your help. I am sure as I
program these deals I will have more questions. Below is
the Code that I ended up with and that works with what I
am trying to do, I hope it will benefit the rest of the
group.

Please let me know if it is in bad taste to start a new
post, I figured that since the solution would be burried
it would benefit more in a new string.

Thank you,

Aaron

****************************************************
Begin solution
****************************************************
Sub CleanItemOverages()

Dim iLn1 As Integer ' Line 1 of 2
Dim iLn2 As Integer ' Line 2 of 2
Dim iStr As Integer ' line to start with
Dim iEnd As Integer ' line to stop at

With ActiveWindow ' word bug workaround
.View = wdPrintView
.View = wdNormalView
.View = wdPrintView
End With

iStr = 14

Selection.ExtendMode = False
Selection.GoTo what:=wdGoToLine, which:=wdGoToFirst,
Count:=iStr

With Selection
.Collapse
.ExtendMode = False
iLn1 = .Information(wdFirstCharacterLineNumber)
.Bookmarks("\line").Select
If Len(.Range.Text) > 60 Then
If .Range.Characters(28) <> " " Then
.Range.Characters(26).Select 'was 26
.MoveRight Count:=3, Extend:=wdExtend
If Selection.Range.Text = "pay " Then
End
Else
Selection.MoveUp Unit:=wdLine, Count:=1
Call CleanLine
End If
End If
End If
.MoveDown
iLn2 = .Information(wdFirstCharacterLineNumber)
While iLn1 <> iLn2
.Bookmarks("\line").Select
If Len(.Range.Text) > 60 Then
If .Range.Characters(28) <> " " Then
.Range.Characters(26).Select 'was 26
.MoveRight Count:=3, Extend:=wdExtend
If Selection.Range.Text = "pay " Then
End
Else
Selection.MoveUp Unit:=wdLine, Count:=1
Call CleanLine
End If
End If
End If
iLn1 = .Information(wdFirstCharacterLineNumber)
.MoveDown
iLn2 = .Information(wdFirstCharacterLineNumber)
Wend
End With

End Sub

********************************
CleanLine
********************************
Sub CleanLine()
Selection.MoveRight Unit:=wdCharacter, Count:=24
Selection.TypeParagraph
Selection.TypeText Text:=vbTab & vbTab & " "
Selection.MoveRight Unit:=wdCharacter, Count:=14
Selection.MoveRight Unit:=wdCharacter, Count:=21,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=5
End Sub
 
H

Helmut Weber

Hi Aaron,
I think, starting a new thread is alright,
must be, as long as nobody of the all time
great experts says something against it.
selection.Information(wdFirstCharacterLineNumber)
could be written as selection.Information(10).
Hard too understand when reading it some
time later, though.
Msgbox wdFirstCharacterLineNumber returns 10.
In the VBE, F2 opens a window with the object catalog.
Search for wdFirstCharacterLineNumber.
You see this at the bottom of the window:
Const wdFirstCharacterLineNumber = 10
Element von Word.WdInformation ' german version
 
A

Aaron

Got it! Thank you for your time and help Helmut! Look
forward to talking with you in the future.
 

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