PDA

View Full Version : [SOLVED:] Selection.InsertFile Changes Formatting



Mavila
05-10-2017, 06:56 AM
I'm creating a single document from the contents of several other documents. I do this using Selection.InsertFile. Before each InsertFile, I insert a SectionBreak(Next Page).

This all works really well for me except for this one source file which changes the font (increase the size from 8 to 11) when I do the Selection.InsertFile. I've tried many things to resolve this such as copying the contents of the source file into a clean/fresh document and reworking the contents (rewriting/configuring the contents, although not recreated entirely from scratch). If I do Selection.InsertFile into a new/clean document, it does the same thing so it doesn't seem to be something to do with the destination file.

I've read this may have to do with Styles. However, I'm not sure I fully understand this. I know there are built-in styles and you can also create your own custom styles. On other source files, I've created a couple of custom styles and these are not distorted on Selection.InsertFile. So, I don't understand why this particular source file always gets distorted no matter what I do.

If anyone can help me sort this out and find a fix for it, I would be grateful.

gmayor
05-10-2017, 07:02 AM
It sounds like the inserted file has different style definitions for the same style names from the document you are inserting into.

Mavila
05-10-2017, 07:13 AM
Thanks for the reply. I think that's possible.

How does one go about reconciling that?

Attempting an edit. Ha! Let me do it that time.

Mavila
05-10-2017, 07:15 AM
I tried to edit that last post but I it doesn't seem to want to let me do that.

I think that's possible but I created a fresh/new document and copied the source text over trying to overcome that but it doesn't work.

Mavila
05-10-2017, 09:02 AM
I have solved this.

First, I tried to reconcile the Styles by going into Manage Styles, then clicking on Import/Export. From there I copied each of the Styles listed in the box under Normal.dotm over into the source document. It confirms if you want to overwrite the Style in the source document and I click Yes. I thought this would reconcile the Styles. Unfortunately, I was having the same problem.

So, I basically had to start from scratch. I copied the contents of the source file over to a new document and did a Paste Text Only. I reformatted everything and now it works.

It's going to take a lot more time and effort but I guess that's what I have to do. I wish there was another way.

gmayor
05-10-2017, 11:15 PM
If you had copied the styles from the target document to the source document then CTRL+A to select the document content, followed by CTRL+Q would reset the styles and CTRL+Space would reset the fonts. This will however remove any manual formatting.

macropod
05-10-2017, 11:50 PM
Instead of using the InsertFile method, you may do better to open the source file and use the FormattedText method to replicate the content. Or you could use copy/paste special.