Splitting a document

E

Edgar

Hi All

Thanks to Doug, Bruce and Helmut for helping me with the
Splitting of a document.

I have used Doug Robbins version as this works best. The
problem i have and i am not sure if this can be fixed is
when it saves the document to a new file name it loses all
formatting in the document.

The document is created in a program called Crystal
Reports and creates a rich text file as an output, there
is something a bit strange about this file as if i select
all the text in the page and copy to a new file it will
lose all formatting and also will lose a logo we have at
the top of the Page.

Each part of the text is formatted with what i think is a
frame around it.

What i guess i am trying to say is, is there a way to copy
all formats and pictures to a new document instead of just
all the text?

Let me know if you need any more info.

Many thanks

Edgar Thoemmes
 
D

Dave Lett

Hi Edgar

I don't know the history of your questions, but I think if you use

NewDocument.Range.FormattedText = OldDocument.Range.FormattedTex

you will get the results that you're looking for. NewDocument and OldDocument only represent the two or more documents you might be working with. The key part is to use Range.FormattedText

HTH,
Dave
 
S

Splitting a document

Hi Dave

Thank you for this it has worked quite well. Unfortunatley
there are still a couple of frames which do not copy to
the new document.

There is also a auto shape frame around it similar to a
table border which didnt copy.

Do you know why this is?

I have pasted the code below for your reference.

Sub Splitter()

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.FormattedText =
arange.FormattedText
arange.Delete
Target.SaveAs fname
Target.Close
Loop
End With
End Sub


-----Original Message-----
Hi Edgar,

I don't know the history of your questions, but I think if you use

NewDocument.Range.FormattedText = OldDocument.Range.FormattedText

you will get the results that you're looking for.
NewDocument and OldDocument only represent the two or more
documents you might be working with. The key part is to
use Range.FormattedText.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top