Document Formatting

M

Mike

Anyone have any suggestions. I am trying to insert one
document into another. When I cut and paste or instert
another document into an existing document the formatting
is lost. I have tried both page and section breaks and
this does not solve the problem. I have also tried to
insert a file command and the same thing happens. How do
I keep the format of the new document I have inserted?
 
L

Larry

Here's a macro that overcomes this tricky problem. It keeps all
formatting when pasting text into a document in which Normal style has a
different font. Select the text that you want to paste into another
document and run the macro. The macro applies the font of the first
character of each paragraph in the selection back onto the whole
paragraph. It then copies the selection, then undoes the change so that
the original text remains exactly as it was. Then you simply paste the
contents of the clipboard into the other document, and it keeps its
formatting, regardless of whether it originally had formatting on top of
the style of not. So, if the destination document has Normal style as
Arial, and the source document as Normal style as Courier, when you
paste the text into the destination document will appear as Courier.

(This is probably not the most orthodox way of doing this because it
involves applying font formatting on top of styles. However, for
occasional needs, you may find it comes in handy.)

Larry

Sub ReapplyFontToSelectedParasAndCopy()
' by Larry

If MsgBox("Reapply font to each selected paragraph " & vbCr _
& "and copy selection.", vbOKCancel, "Reapply Font") = vbOK Then

Application.ScreenUpdating = False
X = Selection.Paragraphs.Count
Dim myFontName As String
Dim myPara As Paragraph

For Each myPara In Selection.Paragraphs
myFontName = myPara.Range.Characters(1).Font.Name
myPara.Range.Font.Name = myFontName
Next myPara
Selection.Copy
ActiveDocument.Undo X
Else
Selection.Collapse wdCollapseStart
System.Cursor = wdCursorIBeam
End If

End Sub
 
L

Larry

I should have mentioned that this macro only preserves the font
formatting, not paragraph formatting.

Larry
 
D

Dave Neve

Hi Everyone

Mike. You haven't told us your system. I'm on XP and Style in XP includes
foramtting.

If you define and save your desired style, you can then simply apply it to
the new 'dissident' paragraph.

Regards

..
 

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