Combining document with disparate styles

  • Thread starter Peter Bernhardt
  • Start date
P

Peter Bernhardt

I'm working on a project where I'm automatically combining two or more
documents and I need to apply a consistent font throught the combined
document. The problem is that doc A may have a style named X that uses a
Helvetica font while doc B will have a style named Y that uses a Times Roman
font. I have to apply a common style, but first I need to determine if these
styles should be the same or if one is a heading style and the other a body
text style. And I also won't know at runtime what styles to expect from the
various documents I'll be assembling.

Is the only solution to this problem to iterate through all the styles in a
given document and do some basic heuristics on the discovered styles? For
example, look at the properties of style X and decide if it is a heading
style and then change the style a more generic style that is the best fit.
Or would it be simpler to just update the font of all styles to use a
pre-determined font family?

Any ideas would be greatly appreciated.

TIA
 
P

Peter

I think what you might want to do is iterate through the paragraphs of the applicable documents, examining the paragraph styles and converting appropriately:

Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs

Select Case para.Style

Case wdStyleNormal
' copy and convert to some normalized style
Case wdStyleHeading1
' copy and convert to some normalized style
Case wdStyleHeading2
' copy and convert to some normalized style
Case wdStyleHeading3
' copy and convert to some normalized style
Case Else
' ...
End Select

Next para

hth,

-Peter
 

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