text size changes

S

sals

I have this code to extract files from one folder and to combine them
into one large document. Each file has a text boxes at the top of the
document, inside it, there are text with different styles and font
sizes. Once I merge them togehter, some of the font sizes changed
from 10 to 12 and is causing the text to be scattered and expanded
every where.

How do I get all the text and format to stay exactly the same?
Or is there a better approach at this?


Thanks,

S

_____________________________________________________________
Sub mergeDoc()

activeDir = "F:\doc"

With Application.FileSearch
.LookIn = activeDir 'folder with old files
End With

'move to the end of the document to insert files
Selection.EndKey Unit:=wdStory, Extend:=wdMove

With Application.FileSearch
.NewSearch
.LookIn = activeDir
.SearchSubFolders = False
.FileName = "*.doc"
.MatchTextExactly = False
If .Execute() > 0 Then

For i = 1 To .FoundFiles.Count
Selection.InsertFile FileName:=.FoundFiles(i),
Range:="", _
ConfirmConversions:=False, Link:=False,
Attachment:=False
Selection.InsertBreak Type:=wdSectionBreakOddPage
Next i

'Remove Final Section Break
Selection.EndKey Unit:=wdStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1

End With


End Sub
 
D

DA

I suspect you're having clashes with the styles used
between the working document and the one you're
inserting. The incoming doc will adopt the style setting
from the working document if you're using the same style
definitions. I wouldn't be surprised if you're also
importing new styles as you bring in documents.

What you no doubt end up with is a mix of paragraph and
character styles.

It's hard to point to a solution without knowing what
sort of a mess your styles end up with. If you do't end
up with a zillion styles by the time your import is done,
I would try loading the template and updating your styles
as required.

e.g. the floowing loads template, set Heading 1 style,
saves template, then updates the doc.
----------
Set tempDoc =
ActiveDocument.AttachedTemplate.OpenAsDocument
With tempDoc.Styles(wdStyleHeading1).Font
.Name = "Arial"
.Size = 16
End With
tempDoc.Close SaveChanges:=wdSaveChanges
ActiveDocument.UpdateStyles
 
S

sals

Hi DA,

Thanks for taking the time to give me such a detail explainnation.

I changed your code to Arial 10 pt, which is what the after merge
document is not displaying. I've also saved this style into the after
merge document.
But still, it is changing to 12pt.

In my to be merged documents, there is a text box around the Arial
10pt and 12 pt text. When I selected to reveal the style, the style
is shown with a border around some of the font. I added both styles
to the template.

again nothing happened.
anything else I can try?

Thanks,

S
________________
 

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