How to remove MS WORD frames properly?

Hello experts!

  I've run into the save situation as many many others here: there is generated MS WORD
document having frames. My DOC document was prepared by Oracle Reports 10g software. The problem is the same: multiple frames do not allow me to edit generated document in
MS Word. I've tried the macros published here as a solutions of similar problems, but they
messed up my DOC file: all alignments were destroyed...
   Having long time experience in Oracle, I have very limited knowledge of VB.
   Please, help me to improve the following macro so that it produces a file with
frames removed and all alignments of text and paragraphs to be the same as in the original

Sub DeleteAllDocframes()
    Dim frm As Frame
    Dim rng As Range
    Dim brd As Border
    Dim para As Paragraph
    For Each frm In ActiveDocument.Frames
        Set rng = frm.Range
        'Delete the borders left behind
        For Each para In rng.Paragraphs
            For Each brd In para.Borders
                brd.LineStyle = wdLineStyleNone
            Next brd
        Next para
    Next frm
End Sub

 To make your work a little bit easier, I've attached my DOC document.
All data mentioned in it are synthetic (for testing purposes).
  Thanks a lot in advance!


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think that the software has used frames so that each piece of text can be positioned precisely.

The positioning is quite variable and complex, with different alignments within the frames. It would be very difficult to achieve the same layout without frames (or text boxes), and to write some code to convert the document automatically would be more of a project than a tip.

The first two frames are no problem. The second and third are at the same vertical displacement, so their two paragraphs would need to be rejoined into a single paragraph, separated by a tab character with the tab stop positioned where the second frame in the line starts. The next few lines are the same except that the lines would need indenting. The address lines are a real problem. The text has central alignment, but does not use the page centre, but a position about five centimetres from the left-hand margin

Can you tell us what difficulty you are having in editing the document? Perhaps there is another way around that.
Andrey-21Author Commented:
Hello Graham Skan!

  Thanks a lot for looking into the issue! I appreciate your describes of the file structure features.
Regarding to your question about issue of editing the file I can say the following: I have to add
some new rows at any section (common info, addresses, education etc). For a while the only way
to edit the file is to add  (or edit) existing content in those frames only. I'm experiencing real troubles
trying insert new empty space (rows) between the frames to be able to type some other text
in it. The problem becomes even worse because such an operations (adding a new lines) have to be
done at virtually any location in the file.
  So, Graham if you give me a tip how that can be done - it would be a real help for me.
Thanks a lot anyway!

I have done a lot of Googling without finding an off-the-shelf product to remove the frames and still keep the layout. I have refound another macro that I wrote for this conversion, but it isn't perfect. It is in the snippet below

As I indicated before, developing a more rigorous solution is beyond the scope of this site, though I am sure that better code could be written with quite a long of effort.

FYI, some experts will take on this sort of work for a fee. For any that do, it will be shown in their profiles.

Sub DelFrames()
    Dim aFrame As Frame
    Dim p As Paragraph
    Dim l As Single

    For Each aFrame In ActiveDocument.Frames
       aFrame.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
       l = aFrame.HorizontalPosition
       For Each p In aFrame.Range.Paragraphs
          p.LeftIndent = l
       Next p
    Next aFrame
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.