Hi

The supplier reference will be a 6 digit number starting
with a 1. Let me know if you need any more info.

E


>-----Original Message-----
>Edgar,
>
>Give us some more information about how the supplier
reference can be
>identified.
>
>--
>Please post any further questions or followup to the
newsgroups for the
>benefit of others who may be interested. Unsolicited
questions forwarded
>directly to me will only be answered on a paid consulting
basis.
>Hope this helps
>Doug Robbins - Word MVP
>"Edgar" <anonymous@discussions.microsoft.com> wrote in
message
>news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
>> Hi
>>
>> Not sure if this is possible but i have a large document
>> that is generated from Crystal Reports and is saved in
rtf
>> format.
>>
>> This report is lots of different remittances for
suppliers
>> but we cannot split this up to individual suppliers from
>> Crystal so at the moment we are forced to email page
>> ranges which is very time consuming.
>>
>> The problem is the remittances range from 1 page to 15
>> pages so i would need to set up some kind of loop to
check
>> the supplier reference and then for it to save as the
>> supplier reference.
>>
>> The supplier reference is always in the same place on
the
>> document so is it possible to set a marker on this to be
>> used in a loop. Sorry but i know next to nothing about
>> word vba. Thanks in advance for your help.
>>
>> Edgar
>
>

Re: Splitting a Document by Helmut

Helmut
Mon Jan 26 13:30:54 CST 2004

Hi Edgar,
in principle you have to search the doc for the
seperator, the 6 digit number, create a new document,
set it's range for the range, that your search procedure defines,
save it with a name, defined by the 6 digit number,
cut off the range, that the search procedure defined, etc.
Which is highly imperfect, but could be a start.
Not quite simple, though. Some questions still remain.
Sub Makro2()
Dim d1 As Document
Dim d2 As Document
Dim r1 As Range
Dim r2 As Range
Dim s As String
Set d1 = ActiveDocument
Set r1 = d1.Range
With r1.Find
.Text = "1[0-9]{5}"
.MatchWildcards = True
.Execute
If .Found Then
s = r1.Text
r1.Start = 0
Set d2 = Documents.Add()
Set r2 = d2.Range
r2 = r1
r1.Delete
d2.SaveAs "c:\test\" & s & ".doc"
End If
End With
End Sub




Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word XP, Win 98


Re: Splitting a Document by EmpyreanEmpathy

EmpyreanEmpathy
Mon Jan 26 15:18:27 CST 2004

Edgar

This is kind of a crude one. It searches for any six digit number
starting with 1 and puts in a section break before it. Then it goes
back to each supplier reference number and selects the entire section
to be e-mailed.

Doug will probably have something more operationally efficient, but
maybe this can serve as a small primer on ranges and how to find text
with them. - Bruce

Sub SupplierRefSections ()
Dim R As Range, Sec As Section, Cnt As Long
Set R = ActiveDocument.Range
With R.Find
.Text = "1^#^#^#^#^#"
Do While .Execute
R.InsertBreak Type:=wdSectionBreakNextPage
R.MoveEndWhile "1234567890"
R.Font.Color = wdColorRed
R.Font.Bold = True
Cnt = Cnt + 1
ActiveDocument.Bookmarks.Add Range:=R, Name:="SupplierRef" &
Cnt
Do While R.Information(wdWithInTable) = True
R.MoveEnd wdParagraph
Loop
R.Collapse wdCollapseEnd
Loop
End With
For Cnt = 1 To Cnt
Selection.GoTo What:=wdGoToBookmark, Name:="SupplierRef" & Cnt
MsgBox "Supplier Ref No"
Selection.Sections(1).Range.Select
MsgBox "Section to be e-mailed to supplier"
Next
End Sub


"Edgar" <anonymous@discussions.microsoft.com> wrote in message news:<3fe501c3e416$771a4690$a101280a@phx.gbl>...
> Hi
>
> The supplier reference will be a 6 digit number starting
> with a 1. Let me know if you need any more info.
>
> E
>
>
> >-----Original Message-----
> >Edgar,
> >
> >Give us some more information about how the supplier
> reference can be
> >identified.
> >
> >--
> >Please post any further questions or followup to the
> newsgroups for the
> >benefit of others who may be interested. Unsolicited
> questions forwarded
> >directly to me will only be answered on a paid consulting
> basis.
> >Hope this helps
> >Doug Robbins - Word MVP
> >"Edgar" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
> >> Hi
> >>
> >> Not sure if this is possible but i have a large document
> >> that is generated from Crystal Reports and is saved in
> rtf
> >> format.
> >>
> >> This report is lots of different remittances for
> suppliers
> >> but we cannot split this up to individual suppliers from
> >> Crystal so at the moment we are forced to email page
> >> ranges which is very time consuming.
> >>
> >> The problem is the remittances range from 1 page to 15
> >> pages so i would need to set up some kind of loop to
> check
> >> the supplier reference and then for it to save as the
> >> supplier reference.
> >>
> >> The supplier reference is always in the same place on
> the
> >> document so is it possible to set a marker on this to be
> >> used in a loop. Sorry but i know next to nothing about
> >> word vba. Thanks in advance for your help.
> >>
> >> Edgar
> >
> >

Re: Splitting a Document by Doug

Doug
Tue Jan 27 03:03:31 CST 2004

Hi Edgar,

If you run a macro containing the following code when the document is
active, it will save each portion as a separate document with the filename
being the supplier reference:

Dim Source As Document, Target As Document, arange As Range, fname As
String
Set Source = ActiveDocument
Selection.EndKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="1[0-9]{5}", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=False) = True
Set arange = Selection.Range
fname = arange.Text
arange.End = Source.Range.End
Set Target = Documents.Add
Target.Range = arange
arange.Delete
Target.SaveAs fname
Target.Close
Loop
End With


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Edgar" <anonymous@discussions.microsoft.com> wrote in message
news:3fe501c3e416$771a4690$a101280a@phx.gbl...
> Hi
>
> The supplier reference will be a 6 digit number starting
> with a 1. Let me know if you need any more info.
>
> E
>
>
>>-----Original Message-----
>>Edgar,
>>
>>Give us some more information about how the supplier
> reference can be
>>identified.
>>
>>--
>>Please post any further questions or followup to the
> newsgroups for the
>>benefit of others who may be interested. Unsolicited
> questions forwarded
>>directly to me will only be answered on a paid consulting
> basis.
>>Hope this helps
>>Doug Robbins - Word MVP
>>"Edgar" <anonymous@discussions.microsoft.com> wrote in
> message
>>news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
>>> Hi
>>>
>>> Not sure if this is possible but i have a large document
>>> that is generated from Crystal Reports and is saved in
> rtf
>>> format.
>>>
>>> This report is lots of different remittances for
> suppliers
>>> but we cannot split this up to individual suppliers from
>>> Crystal so at the moment we are forced to email page
>>> ranges which is very time consuming.
>>>
>>> The problem is the remittances range from 1 page to 15
>>> pages so i would need to set up some kind of loop to
> check
>>> the supplier reference and then for it to save as the
>>> supplier reference.
>>>
>>> The supplier reference is always in the same place on
> the
>>> document so is it possible to set a marker on this to be
>>> used in a loop. Sorry but i know next to nothing about
>>> word vba. Thanks in advance for your help.
>>>
>>> Edgar
>>
>>
>



Re: Splitting a Document by Doug

Doug
Tue Jan 27 03:04:49 CST 2004

Hi Bruce,

See my response to Edgar. This is a case where it is easiest to start at
the end of the document and work forward as then all you have to do is find
the start of each section.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Bruce Brown" <EmpyreanEmpathy@aol.com> wrote in message
news:1d2f086c.0401261318.69bb0e04@posting.google.com...
> Edgar
>
> This is kind of a crude one. It searches for any six digit number
> starting with 1 and puts in a section break before it. Then it goes
> back to each supplier reference number and selects the entire section
> to be e-mailed.
>
> Doug will probably have something more operationally efficient, but
> maybe this can serve as a small primer on ranges and how to find text
> with them. - Bruce
>
> Sub SupplierRefSections ()
> Dim R As Range, Sec As Section, Cnt As Long
> Set R = ActiveDocument.Range
> With R.Find
> .Text = "1^#^#^#^#^#"
> Do While .Execute
> R.InsertBreak Type:=wdSectionBreakNextPage
> R.MoveEndWhile "1234567890"
> R.Font.Color = wdColorRed
> R.Font.Bold = True
> Cnt = Cnt + 1
> ActiveDocument.Bookmarks.Add Range:=R, Name:="SupplierRef" &
> Cnt
> Do While R.Information(wdWithInTable) = True
> R.MoveEnd wdParagraph
> Loop
> R.Collapse wdCollapseEnd
> Loop
> End With
> For Cnt = 1 To Cnt
> Selection.GoTo What:=wdGoToBookmark, Name:="SupplierRef" & Cnt
> MsgBox "Supplier Ref No"
> Selection.Sections(1).Range.Select
> MsgBox "Section to be e-mailed to supplier"
> Next
> End Sub
>
>
> "Edgar" <anonymous@discussions.microsoft.com> wrote in message
> news:<3fe501c3e416$771a4690$a101280a@phx.gbl>...
>> Hi
>>
>> The supplier reference will be a 6 digit number starting
>> with a 1. Let me know if you need any more info.
>>
>> E
>>
>>
>> >-----Original Message-----
>> >Edgar,
>> >
>> >Give us some more information about how the supplier
>> reference can be
>> >identified.
>> >
>> >--
>> >Please post any further questions or followup to the
>> newsgroups for the
>> >benefit of others who may be interested. Unsolicited
>> questions forwarded
>> >directly to me will only be answered on a paid consulting
>> basis.
>> >Hope this helps
>> >Doug Robbins - Word MVP
>> >"Edgar" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
>> >> Hi
>> >>
>> >> Not sure if this is possible but i have a large document
>> >> that is generated from Crystal Reports and is saved in
>> rtf
>> >> format.
>> >>
>> >> This report is lots of different remittances for
>> suppliers
>> >> but we cannot split this up to individual suppliers from
>> >> Crystal so at the moment we are forced to email page
>> >> ranges which is very time consuming.
>> >>
>> >> The problem is the remittances range from 1 page to 15
>> >> pages so i would need to set up some kind of loop to
>> check
>> >> the supplier reference and then for it to save as the
>> >> supplier reference.
>> >>
>> >> The supplier reference is always in the same place on
>> the
>> >> document so is it possible to set a marker on this to be
>> >> used in a loop. Sorry but i know next to nothing about
>> >> word vba. Thanks in advance for your help.
>> >>
>> >> Edgar
>> >
>> >



Re: Splitting a Document by EmpyreanEmpathy

EmpyreanEmpathy
Tue Jan 27 10:29:01 CST 2004

Doug,

Agree that it makes better sense to search backwards.

Curious, though - is there some reason you prefer selection find over
range find in this case, since either can be used? - Bruce


"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS" <dkr@mOSTvALUABLEpROFESSIONALs.org> wrote in message news:<#1XJwRL5DHA.1816@TK2MSFTNGP12.phx.gbl>...
> Hi Edgar,
>
> If you run a macro containing the following code when the document is
> active, it will save each portion as a separate document with the filename
> being the supplier reference:
>
> Dim Source As Document, Target As Document, arange As Range, fname As
> String
> Set Source = ActiveDocument
> Selection.EndKey wdStory
> Selection.Find.ClearFormatting
> With Selection.Find
> Do While .Execute(FindText:="1[0-9]{5}", MatchWildcards:=True,
> Wrap:=wdFindContinue, Forward:=False) = True
> Set arange = Selection.Range
> fname = arange.Text
> arange.End = Source.Range.End
> Set Target = Documents.Add
> Target.Range = arange
> arange.Delete
> Target.SaveAs fname
> Target.Close
> Loop
> End With
>
>
> --
> Please post any further questions or followup to the newsgroups for the
> benefit of others who may be interested. Unsolicited questions forwarded
> directly to me will only be answered on a paid consulting basis.
> Hope this helps
> Doug Robbins - Word MVP
> "Edgar" <anonymous@discussions.microsoft.com> wrote in message
> news:3fe501c3e416$771a4690$a101280a@phx.gbl...
> > Hi
> >
> > The supplier reference will be a 6 digit number starting
> > with a 1. Let me know if you need any more info.
> >
> > E
> >
> >
> >>-----Original Message-----
> >>Edgar,
> >>
> >>Give us some more information about how the supplier
> reference can be
> >>identified.
> >>
> >>--
> >>Please post any further questions or followup to the
> newsgroups for the
> >>benefit of others who may be interested. Unsolicited
> questions forwarded
> >>directly to me will only be answered on a paid consulting
> basis.
> >>Hope this helps
> >>Doug Robbins - Word MVP
> >>"Edgar" <anonymous@discussions.microsoft.com> wrote in
> message
> >>news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
> >>> Hi
> >>>
> >>> Not sure if this is possible but i have a large document
> >>> that is generated from Crystal Reports and is saved in
> rtf
> >>> format.
> >>>
> >>> This report is lots of different remittances for
> suppliers
> >>> but we cannot split this up to individual suppliers from
> >>> Crystal so at the moment we are forced to email page
> >>> ranges which is very time consuming.
> >>>
> >>> The problem is the remittances range from 1 page to 15
> >>> pages so i would need to set up some kind of loop to
> check
> >>> the supplier reference and then for it to save as the
> >>> supplier reference.
> >>>
> >>> The supplier reference is always in the same place on
> the
> >>> document so is it possible to set a marker on this to be
> >>> used in a loop. Sorry but i know next to nothing about
> >>> word vba. Thanks in advance for your help.
> >>>
> >>> Edgar
> >>
> >>
> >

Re: Splitting a Document by Doug

Doug
Tue Jan 27 14:58:56 CST 2004

Hi Bruce,

There is no reason that I used Selection instead of Range other than that
was what was used by the macro that I modified for this purpose.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Bruce Brown" <EmpyreanEmpathy@aol.com> wrote in message
news:1d2f086c.0401270829.76988627@posting.google.com...
> Doug,
>
> Agree that it makes better sense to search backwards.
>
> Curious, though - is there some reason you prefer selection find over
> range find in this case, since either can be used? - Bruce
>
>
> "Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
> <dkr@mOSTvALUABLEpROFESSIONALs.org> wrote in message
> news:<#1XJwRL5DHA.1816@TK2MSFTNGP12.phx.gbl>...
>> Hi Edgar,
>>
>> If you run a macro containing the following code when the document is
>> active, it will save each portion as a separate document with the
>> filename
>> being the supplier reference:
>>
>> Dim Source As Document, Target As Document, arange As Range, fname As
>> String
>> Set Source = ActiveDocument
>> Selection.EndKey wdStory
>> Selection.Find.ClearFormatting
>> With Selection.Find
>> Do While .Execute(FindText:="1[0-9]{5}", MatchWildcards:=True,
>> Wrap:=wdFindContinue, Forward:=False) = True
>> Set arange = Selection.Range
>> fname = arange.Text
>> arange.End = Source.Range.End
>> Set Target = Documents.Add
>> Target.Range = arange
>> arange.Delete
>> Target.SaveAs fname
>> Target.Close
>> Loop
>> End With
>>
>>
>> --
>> Please post any further questions or followup to the newsgroups for the
>> benefit of others who may be interested. Unsolicited questions forwarded
>> directly to me will only be answered on a paid consulting basis.
>> Hope this helps
>> Doug Robbins - Word MVP
>> "Edgar" <anonymous@discussions.microsoft.com> wrote in message
>> news:3fe501c3e416$771a4690$a101280a@phx.gbl...
>> > Hi
>> >
>> > The supplier reference will be a 6 digit number starting
>> > with a 1. Let me know if you need any more info.
>> >
>> > E
>> >
>> >
>> >>-----Original Message-----
>> >>Edgar,
>> >>
>> >>Give us some more information about how the supplier
>> reference can be
>> >>identified.
>> >>
>> >>--
>> >>Please post any further questions or followup to the
>> newsgroups for the
>> >>benefit of others who may be interested. Unsolicited
>> questions forwarded
>> >>directly to me will only be answered on a paid consulting
>> basis.
>> >>Hope this helps
>> >>Doug Robbins - Word MVP
>> >>"Edgar" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >>news:455901c3e3fd$f54ed080$a401280a@phx.gbl...
>> >>> Hi
>> >>>
>> >>> Not sure if this is possible but i have a large document
>> >>> that is generated from Crystal Reports and is saved in
>> rtf
>> >>> format.
>> >>>
>> >>> This report is lots of different remittances for
>> suppliers
>> >>> but we cannot split this up to individual suppliers from
>> >>> Crystal so at the moment we are forced to email page
>> >>> ranges which is very time consuming.
>> >>>
>> >>> The problem is the remittances range from 1 page to 15
>> >>> pages so i would need to set up some kind of loop to
>> check
>> >>> the supplier reference and then for it to save as the
>> >>> supplier reference.
>> >>>
>> >>> The supplier reference is always in the same place on
>> the
>> >>> document so is it possible to set a marker on this to be
>> >>> used in a loop. Sorry but i know next to nothing about
>> >>> word vba. Thanks in advance for your help.
>> >>>
>> >>> Edgar
>> >>
>> >>
>> >