Re: "Find this, insert page break": what approach?



Good idea! Use InStr to return the position of the text strings, and I can
repeat that as much as needed to confirm I am where I need to be. Thanks
Kevin.

Ed

"Kevin B" <kbackmann@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BEF42B25-F430-47D5-B9A2-A299344F491A@xxxxxxxxxxxxxxxx
> Maybe this would work or point in the general direction:
>
> Sub FindStuff()
>
> Dim strLine As String
> Dim rng As Range
> Dim blnDone As Boolean
>
> 'Move to start of document
> Selection.HomeKey unit:=wdStory
>
> 'Loop through the document, looking on each line for
> 'either "Test Text" or "Indented Text"
> Do Until blnDone = True
> 'Select each line and verify that the end of the document
> 'has not been reached. If not, search for indicated text
> With Selection
> .HomeKey unit:=wdLine
> .EndKey unit:=wdLine, Extend:=wdExtend
> If .End = ActiveDocument.Content.End Then blnDone = True
> strLine = .Text
> End With
> 'If the text is found, insert page break
> If InStr(1, strLine, "Test text") > 1 Or InStr(1, strLine,
"Indented
> Text") > 1 Then
> Selection.HomeKey unit:=wdLine
> Selection.InsertBreak Type:=wdPageBreak
> End If
> Selection.MoveDown unit:=wdLine
> Loop
>
> End Sub
>
> --
> Kevin Backmann
>
>
> "Ed" wrote:
>
> > A report generated by an old database program dumps everything out in
one
> > long continuous file. That can not be changed. The resulting text file
is
> > opened in Word, and the users run a macro I wrote that finds the first
line
> > of each new record in the report and inserts a page break, so each new
> > record begins on a new page. All runs well - until someone changes that
> > first line! It's hard-coded into the macro as the string for "Find.Text
=
> > strFind". Then, of course, it's my macro that's broke!
> >
> > The header for each new record in the report has four lines. Each line
is a
> > separate paragraph. Each line will report the same item of information,
> > such as:
> > ITEM NO: SER NO:
> > COLOR: BIN NO:
> > The information at each label may or may not change, but these labels
will
> > remain fixed at their character positions in each line at each report
> > header. (For instance, whether COLOR: is "blue" or "chartreuse", the
BIN
> > NO: label will always be at the same character position.)
> >
> > Is there an easy way to tell the macro to "find three or four paragraphs
> > with these labels at these character positions", while disregarding
whatever
> > information may be presented at the label?
> >
> > Ed
> >
> >
> >


.



Relevant Pages

  • Report forcing new page for NO Reason
    ... I have a report that is rather long but very simple. ... with strings as well as many labels for things that don't ever change. ... Same with my first footer section. ... Even stranger I moved the last label from the detail section to ...
    (microsoft.public.access.reports)
  • Re: Fields in Label dont give correct information
    ... tables where the data was stored in the query the query would not run. ... half the time with very few errors (other than that label problem I had.) ... report all of the information shows up on the report the way I want it to. ... For example in the Room assignment on the report an idividual will be ...
    (microsoft.public.access.reports)
  • Re: Fields in Label dont give correct information
    ... You need to create a query based on tblRegEvent and tblRegPayment. ... -If your DCountis to count values in your report, ... half the time with very few errors (other than that label problem I had.) ... For example in the Room assignment on the report an idividual will be ...
    (microsoft.public.access.reports)
  • Re: Desperate! Pagination problem
    ... The label textboxes in the subreport were getting split across the page ... because sometimes there is no user data for that label and we don't want the ... When I run Access 2000 next to Access 2003 for the same data, same report, ... There are textboxes in the Subreport1 Detail that function as labels for the ...
    (microsoft.public.access.reports)
  • Re: Address Labels, Thanks Fred
    ... >> I am attempting to create a report in Aceess using the Label Wizard. ... > Name this control SkipCounter ...
    (microsoft.public.access.reports)

Loading