I am facing style issues when merging the documents. If you find any solutions for that pls update me. Herewith I attached three documents Doc1.doc, Doc2.doc and Merged.doc.
In Doc1, we have a Style named "BodyText" with the following formatting: AllCaps, Underline. Similarly in Doc2 also we have a style named "BodyText" with the following formatting: Bold, Centered, not AllCaps, Not Underline.
When Merging these documents, I opened the First Document Doc1 and then using insert file optio from insert menu I merged the Doc2 with Doc1 and I save as the file as Merged.doc. I wondered that the Style "BodyText" in Doc2 formatting has been replaced by the Doc1 "BodyText" style formatting. So, Is there any solution to merge the document without any style issues?
Maybe a macro to change the names of all the styles in Doc2 before adding them to Doc1? That way one style won't be overwritten by another.
Something like this (to be run on doc2);
VB Code:
Sub RenameStyles()
Dim sStyle As Style
For Each sStyle In ActiveDocument.Styles
sStyle.NameLocal = "_" & sStyle.NameLocal
Next sStyle
End Sub
I'm not sure how well that works, as it only changes the local name. I don't know if it's possible to change its actual name, but it can't hurt to give it a try
You can also expand the macro so it does the merging of the documents automatically.
Maybe a macro to change the names of all the styles in Doc2 before adding them to Doc1? That way one style won't be overwritten by another.
Something like this (to be run on doc2);
VB Code:
Sub RenameStyles()
Dim sStyle As Style
For Each sStyle In ActiveDocument.Styles
sStyle.NameLocal = "_" & sStyle.NameLocal
Next sStyle
End Sub
I'm not sure how well that works, as it only changes the local name. I don't know if it's possible to change its actual name, but it can't hurt to give it a try
You can also expand the macro so it does the merging of the documents automatically.
Thank you for you kind help! but this code is not working properly. If I run this macro the Heading styles are changing differently. the heading styles are changing to bulleted (Numbering) style. This code will not work for me.