Insert Text From File causes loss of text styles

This problem has been occuring for me for years, and going back multiple versions of Word  2003, 2007 and 2010.   It occurs both programatically using Word's VBA to open a .DOC file and insert the contents of another .DOC file.  And also just opening a .DOC file and using Word's Insert -> Text From File.

It does not happen with every document and so far can't pin it down to any thing specific.  Also, it happens with paragraphs and text that are set to regular fonts (i.e. not using Word Styles) and also when creating custom Word Styles and setting the paragraphs to those styles in the doucment that is to be inserted at the end of an existing document. 

All the fonts do exist and all docs were created the same way on the same computer.  Nothing fancy just plain text.

What happens is when the 2nd document is inserted at the end of the open document.  Sometimes entire paragraphs change to a different font, font color and/or font size.   In tests where I set custom Word Styles.   And the same custom Word Style existed in both documents with the same settings - the paragraphs don't have the style setting anymore in the inserted text.

Most of the time it works, but many times it doesn't.   And when it doesn't work, its usually only portions of the document that loose the formatting.

Any idea why this happens and how to prevent it?

January 19th, 2012 9:35pm

I will continue here, as I don't know how to answer Stefan in the other thread. And as a matter of fact it is code based although you can recreate the scenario manually. I have prepared 2 sample documents - the target and the source, but I don't know how to enclose them. I don't have any "file space" on the "internet". I could email them.

To recapitulate my issue: I have different style settings in the different target documents. The common "thing" is the style name. The thing I want to achieve is that when inserting a source file into the target document, I want the styles of the target document to be the ones that "rule".

My problem is that after inserting a file that has text with applied styles and with the same style names as in the target document, they don't fully adopt the settings of the target document. After the insertion of the source document into the target document, the paragraphs in the target document with the applied style "Punktlista", keep their settings. If you press Shift+F1 to view the settings of a "Punktlista"-paragraph, you will se that there now are some Direct formatting applied. Pressing Ctrl+Q will fix the problem.

I would like that the target style will rule when inserting a file with the same style name applied.

Thanks,
Peeter

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 7:42am

I'm not sure which other thread you are referring to... A link would be helpful.

By default, Word uses the style definition of the target document if there is a conflict. This is usually not a problem, assuming that you leave the paste options set to the defaults in Word Options. But, as I wrote, it may not work properly when bulleted and numbered styles are involved.

Using your sign-in to this forum you already have a OneDrive account. But you can send the files to stefanDOTblomATmvpsDOTorg, and I'll have a look. Be sure to include brief information on the issue in the message and also a link to this thread.

July 4th, 2015 9:48am

Stefan,

Sorry about the thread-thing, I thought this was the Developer forum. I will e-mail you my documents.

Thank you,
Peeter

Free Windows Admin Tool Kit Click here and download it now
July 5th, 2015 2:49am

I have received your documents. If you mean that the vertical spacing (called Spacing Before or Spacing After in English language versions of Word) between numbered paragraphs is incorrect in the target document, then the explanation is as follows: The spacing is incorrect in the source as well. You can see that by clicking in the paragraph and pressing Ctrl+Q. In other words, the fix is to remove direct formatting in the source file before inserting it into the target.

July 5th, 2015 10:38am

Thank you Stefan,

sorry for not explaining more precisely. Firstly it is a mistake that the spacing in the source document isn't according to the style. But isn't it strange that if you examine the settings via Shift+F1, it doesn't inform you of any direct formatting?!

   

Sorry, I had an error in my previous response (now corrected). The direct formatting added is Line Spacing 1.5 (while the rest of the text is set to "Single"). If you select the option (in the Styles pane) to show the source of formatting, you'll see that if you click in the affected paragraph.

Numbering must be set up via Home tab | Multilevel List. See http://shaunakelly.com/word/numbering/numbering20072010.html.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 1:56pm

Hello again, My problem is that the tab setting and right indent doesn't following the style. Any help is appreciated. /Peeter
July 21st, 2015 10:01am

Read the article that Stefan linked. These are set in the list numbering attached to styles.
Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 6:40pm

As Charles has pointed out, it is crucial that you set up numbering correctly. Indentation must be specified in the Multilevel List dialog box. See http://shaunakelly.com/word/numbering/numbering20072010.html.

July 22nd, 2015 8:02pm

Did you use the same Styles in both documents?

See also:

How to control bullets in Ribbon Versions of Word by Shauna Kelly

Free Windows Admin Tool Kit Click here and download it now
July 26th, 2015 2:38pm

I use the same style names and now I have also done as in "How to control bullets in Ribbon Versions of Word by Shauna Kelly".

But it still doesn't work. I enclose a link to 2 documents - target and source -

https://onedrive.live.com/?id=5E2141D59C66DE3A%21119&cid=5E2141D59C66DE3A&group=0<o:p></o:p>


Maybe you can see some oddities there?

Thanks,
Peeter

July 27th, 2015 5:14am

The problem: when I insert the source document into the target document, the bulleted list doesn't follow the style in the target document. Any help is appreciated. /Peeter
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 4:16am

Does anyone have more input on this? Is it a confirmed bug?

Peeter

August 5th, 2015 8:48am

Double check your style names. A space in the name in one document would make it a different style name. There is not a bug in that if the style names are the same and if the style is already in use in the target document, pasted text will adopt the style definition of the target document. Looking at your target document, it is blank. You need to actually use the style you want adopted in that document for it to override the style in the source docu
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2015 11:20am

Thank you for your answer.

The style names are identical in both documents. It is the style with a bulleted list that doesn't work. Other styles, work as intended.  And the target document is empty, because it is built up by inserting other documents into it. So, is it by definition not possible to have such an approach - an empty target document?

When you insert the source document into the target document, do you get the same result?

Thanks,
Peeter

August 12th, 2015 3:09am

Bullets and numbering are different, to some extent. There, the procedures given by Shauna Kelly in the two articles below need to be followed:

How to create numbered headings or outline numbering in Ribbon Versions of Word by Shauna Kelly

How to control bullets in Ribbon Versions of Word by Shauna Kelly

As for inserting source documents into target documents, I have no idea what rules are followed.

Again, if the style is used in the target document first, the target document's style definition will overrule the source document's definition.

Alternatively, you could use the Organizer (Import/Export Styles) to copy one or more style definitions from the target document's template into the target document after the paste.

Free Windows Admin Tool Kit Click here and download it now
August 12th, 2015 3:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics