Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Word-jump to next line

Status
Not open for further replies.

tgoricki

Programmer
Feb 17, 2003
8
HR
I nead to make macro wich will make line in some rows of text.
for example...
"Welcome to an On-Line Biology Book Table of Contents.

NOTES: These pages have been recently (2/97-present) revised and updated. Please let me know your thoughts (mj.somemail@mail.mail)._________________________________

We have been very popular: over 400,000 visitors between Jan. 1, 1999 and September 17, 2001. Thank you!__________
"
i started with.
"
Welcome to an On-Line Biology Book Table of Contents.

NOTES: These pages have been recently (2/97-present) revised and updated. Please let me know your thoughts (mj.farabee@emcmail.maricopa.edu).___

We have been very popular: over 400,000 visitors between Jan. 1, 1999 and September 17, 2001. Thank you!___
"
My problem is that mail and date are variabile lenght and i nead that lines are as long as the row.
I have macro wich puts lines but I can't stop right on the end of the row.

Sub Macro4()

With ActiveDocument.Content.Find
.ClearFormatting
Do While .Execute(FindText:="___", Forward:=True, _
Format:=True) = True

With .Parent
For i = 1 To 100
.InsertBefore "_"
'!!!!! next line is bad and I can't make it work - Help me
If .EndOf(Unit:=wdParagraph, Extend:=wdExtend) Then
i = 100
End If
Next i
.Move Unit:=wdCharacter, Count:=1
End With
Loop
End With
End Sub

Sorry about my english but I hope that someone understand my problem. If not,than ask me more about this!

Thx




Gornet
 
So, you just want to truncate the text? That could be a meaningless string.

1. First you have to TEST to determine IF the text would wrap.
2. If it meets that criteria, THEN you determine what alternative measures to take like decrease the font incrimentally until the text fits. If the font becomes too small then maybe there is another alternative

So, what do you want to do if a TEST were to indicate that the text would wrap?

The answer cannot be what you DON'T want to happen.
The answer must be what you DO want to happen!!!


Skip,
Skip@TheOfficeExperts.com
 
But my problem is that test:
"If .EndOf(Unit:=wdParagraph, Extend:=wdExtend) Then
i = 100
End If"
does not do what I whant (make i=100 and stop inserting "_"), and I nead good version of this part of the code. I nead test which will indicate end of the line...

BDW... Thx for helping me SkipVought
I hawe one more alternative soluton but I have one problem in it... I doesent work in lines of text where I use
{DOCVARIABLE "Name" \* MERGEFORMAT} for inserting values.
code:
Sub macro5()
"
Dim startpar, endpar, currpar, duzina As Integer
Dim repltekst As String
For currpar = 1 To 100
duzina = 0
repltekst = ""
startpar = ActiveDocument.Paragraphs(currpar).Range.Start
''' endpar returning me wrong end of paragraf because it counts in all of the {DOCVARIABLE "Name" \* MERGEFORMAT} not just the value
endpar = ActiveDocument.Paragraphs(currpar).Range.End
lenghtt= 76 - (endpar - startpar) + 3
For i = 1 To duzina
repltekst = repltekst & "_"
Next i
ActiveDocument.Range(startpar, endpar).Select
With Selection.Find
.Text = "___"
.Replacement.Text = "" & repltekst & ""
.Forward = True
.Format = True

End With
Selection.Find.Execute Replace:=wdReplaceAll
Next currpar
End Sub
"

Gornet
 
This is my problem too, because it is my second work in Word VBA and I can't swich so good from Excel VBA in which I'm programing for 2 years now. Personaly, I don't like Word Objects, Properties and Methods because they are not so intuitive as in Excel.

Maybe some1 else knows how to resolve my problem.


Gornet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top