[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

12/03/2007 at 01:53AM PST, ID: 22997092
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

MS Word VBA To Get Paragraphs Within Cell

Asked by dsacker in Microsoft Word

Tags: vba, cell, word

Using a VBA Macro in my Word document, I need to get multiple paragraphs within a table cell and convert them into separate XML objects, each with positioning tags.

For instance, consider the following two cells, of which I will only deal with Cell 1, and consider the two paragraphs within cell 1:

.          Cell 1         .         Cell 2        .
.----------------------.---------------------.
|    Paragraph 1    |                          |
|                            |                          |
| Paragraph 2 will |                          |
| wrap within the  |                          |
| same cell.           |                          |
`---------------------`--------------------`

I need to convert cell 1 to something like the following:

<Rectangle>
    <ReportItems>
        <TextBox>
            <Top>0in</Top>
            <Height>.5in</Height>
            <Value>Paragraph 1</Value>
        </TextBox>
        <TextBox>
            <Top>.5in</Top>
            <Height>1.5in</Height>
            <Value>Paragraph 2 will wrap within the same cell</Value>
        </TextBox>
    </ReportItems>
</Rectangle>

Word indeed exposes 2 separate paragraph objects within that cell object. However, I have scratched around and cannot find the properties of each paragraph object that tell me the relative positioning within that cell.

How do I get the positioning of each paragraph object within its cell object?

Any help is appreciated. Thank you.

Below is some of my code which gets me partially there and may help explain what I am seeking.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
    For Each myRow In myTable.Rows
        For Each myCell In myRow.Cells
            For Each myParagraph In myCell.Range.Paragraphs
                myTopMargin = myParagraph.TopMarginWithinThisCell    ' Does not exist as is, but is what I need
                myHeight = myParagraph.Height                        ' Does not exist as is, but is what I need
                myText = myParagraph.Range.Text                      ' This exists
                Print #1, "<TextBox>"
                Print #1, "    <Top>" & PointsToInches(myTopMargin) & "</Top>"
                Print #1, "    <Height>" & PointsToInches(myHeight) & "</Height>"
                Print #1, "    <Value>" & myText & "</Value>"
                Print #1, "</TextBox>"
            Next myParagraph
        Next myCell
    Next myRow
[+][-]12/03/07 03:24 AM, ID: 20394754

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/03/07 09:38 AM, ID: 20397042

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/04/07 12:41 PM, ID: 20406210

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Word
Tags: vba, cell, word
Sign Up Now!
Solution Provided By: jan_boven_al
Participating Experts: 2
Solution Grade: A
 
 
[+][-]12/04/07 01:53 PM, ID: 20406956

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_EXPERT_20070906