Try the following (Save you document first, it has not been tested!):
Dim Source As Document, target As Document, myrange As Range, i As Long
Set Source = ActiveDocument
i = 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="yourkeyword", MatchWildcards:=False,
Wrap:=wdFindContinue, Forward:=True) = True
Set myrange = Selection.Range
myrange.Start = Source.Start
myrange.Cut
Set target = Documents.Add
target.Range.Paste
target.SaveAs "doc" & i
i = i + 1
Loop
End With

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi,
>
[quoted text clipped - 16 lines]
> P.S: The word document contains chines charactors too along with english
> charactors, and also the images.
Bilal Niaz - 30 May 2005 21:19 GMT
Hi Doug Robbins,
Thankyou very much for the help. It really helped me.
The words comming into my mind regarding your help are nothing in reward of
your effort. But, at least I would like to say "You are Great" :)
Actually, when I tried this snippet. It really worked. But, for only once.
The document which I tried to split contains many repetitions of the key word.
is it possible to keep the repeatitions up untill whole document is searched
and splitted well against the number of repeatitions of the keyword. ?
Here is my code:
Dim Source As Document, target As Document, myrange As Range, i As Long
Dim wd As New Word.Application
Dim wdd As New Word.Document
'Set wdd = New Word.Documents
Set Source = wd.Documents.Open("C:\math.doc")
'Set Source = "C:\math.doc"
i = 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="#@#", MatchWildcards:=False,
Wrap:=wdFindContinue, Forward:=True) = True
Set myrange = Selection.Range
myrange.Start = 0
' you suggested this line : myrange.Start = Source.Start
' but it generated error. So, I used 0 instead. Does it make any difference ?
myrange.Cut
Set target = Documents.Add
target.Range.Paste
target.SaveAs "Docs1" & i
' target.Close
i = i + 1
Loop
----------------------------------------
Many thanks and Best Regards,
Bilal Niaz
> Try the following (Save you document first, it has not been tested!):
>
[quoted text clipped - 36 lines]
> > P.S: The word document contains chines charactors too along with english
> > charactors, and also the images.
Doug Robbins - 31 May 2005 09:02 GMT
Source.Start should have been Source.Range.Start
Sorry about that.
Are you saying that it only acts on the first keyword and then stops?

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi Doug Robbins,
>
[quoted text clipped - 88 lines]
>> > english
>> > charactors, and also the images.
Bilal Niaz - 31 May 2005 10:15 GMT
Hi Doug,
Thanks very much again for the help.
Your previous code helped me and I am happy on that. My problem is to split
a word document into multiple documents depending upone a keyword. And them
those documents should be converted into images.
Here is an example.
suppose I have got a doc file which contains:
---------------------------------------------------------
A quick brown fox jumps over the lazy dog #@#
A quick brown fox jumps over the lazy dog #@#
A quick brown fox jumps over the lazy dog #@#
A quick brown fox jumps over the lazy dog #@#
---------------------------------------------------------
Now, my problem is to split the document into 4 word document and each
document will contain
----------------------------------------------------------------------------
A quick brown fox jumps over the lazy dog
----------------------------------------------------------------------------
But, in current scenerio, it becomes as
----------------------------------------------------------------------------
A quick brown fox jumps over the lazy dog #@#
----------------------------------------------------------------------------
I don't want my keyword to be the part of resulting documents.
Hereis my souce code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="#@#", MatchWildcards:=False,
Wrap:=wdFindContinue, Forward:=True) = True
Set myrange = Selection.Range
myrange.Start = 0
myrange.Cut
Picture1.Cls
Picture1.Picture = Clipboard.GetData
Clipboard.Clear
SavePicture Picture1, strPath & Left(strPath1, Len(strPath1) - 4) &
"\doc" & i & ".Bmp"
stBar.Panels(1).Text = strPath & Left(strPath1, Len(strPath1) - 4) &
"\doc" & i & ".Bmp"
i = i + 1
Loop
End With
Source.Close
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
The above code is working well. Only I don't need the keyword part to be the
part of my resulting documents.
Hope to again have a great cooperation from you.
Many thanks & Best Regards,
Bilal
> Source.Start should have been Source.Range.Start
>
[quoted text clipped - 94 lines]
> >> > english
> >> > charactors, and also the images.