I am using a VBA macro in Word 2002 (office XP) to format a document. One of the things i want to do is place a page
break before the line "PACIFIC RIM LOG SCALING BUREAU, INC
". I only want to put a page break before it if it is NOT the first thing on the page. For example, in the text below
i would want to put " AVG DIA/LEN 12.8/13.7 12.2/12.5" on it's own page. I have code to break before each occurence of the line, but i can't figure out how to test for it not being the first line on a page, as it is i'm getting a lot of totally blank pages before the line.
AVG DIA/LEN 12.8/13.7 12.2/12.5
.
PACIFIC RIM LOG SCALING BUREAU, INC
.
SCALE CERTIFICATE
Here is the code i'm using to break before the line:
<code>
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=1
SearchAgain:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "PACIFIC RIM LOG SCALING"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
If FirstPage = False Then
Selection.HomeKey Unit:=wdLine
Selection.InsertBreak Type:=wdPageBreak
Selection.MoveDown Unit:=wdLine, Count:=1
Else
FirstPage = False
End If
GoTo SearchAgain
End If
</code>
Any ideas? TIA
Ruairi Ruairi
Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
break before the line "PACIFIC RIM LOG SCALING BUREAU, INC
". I only want to put a page break before it if it is NOT the first thing on the page. For example, in the text below
i would want to put " AVG DIA/LEN 12.8/13.7 12.2/12.5" on it's own page. I have code to break before each occurence of the line, but i can't figure out how to test for it not being the first line on a page, as it is i'm getting a lot of totally blank pages before the line.
AVG DIA/LEN 12.8/13.7 12.2/12.5
.
PACIFIC RIM LOG SCALING BUREAU, INC
.
SCALE CERTIFICATE
Here is the code i'm using to break before the line:
<code>
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=1
SearchAgain:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "PACIFIC RIM LOG SCALING"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
If FirstPage = False Then
Selection.HomeKey Unit:=wdLine
Selection.InsertBreak Type:=wdPageBreak
Selection.MoveDown Unit:=wdLine, Count:=1
Else
FirstPage = False
End If
GoTo SearchAgain
End If
</code>
Any ideas? TIA
Ruairi Ruairi
Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.