Author Topic: How to keep diagram with preceding package name in report?  (Read 517 times)

michielper

  • EA User
  • **
  • Posts: 120
  • Karma: +1/-0
    • View Profile
How to keep diagram with preceding package name in report?
« on: August 06, 2018, 01:23:44 am »
I am generating documents with diagrams in EA version 13. Package names are the paragraph headings in my document.
When a package contains a diagram that is not too large, I want the package name (paragraph header) to be on the same page as the diagram and not have a paragraph name followed by a large empty space.
So, I tried the "keep with next" option in my template. When opening the generated document in Word, however, the paragraph heading is NOT marked as "keep with next" and the paragraph heading is attached to the preceding text, is followed by a large empty space and the diagram is on the next page. Not what I want...
I also tried "keep together" but this neither works.

Has anyone else experienced the same problem and perhaps found a solution?


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9399
  • Karma: +260/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to keep diagram with preceding package name in report?
« Reply #1 on: August 06, 2018, 03:51:22 pm »
We use a word macro to
- shrink the images to the correct size so the title
- set certain styles "keep with next"

Geert

michielper

  • EA User
  • **
  • Posts: 120
  • Karma: +1/-0
    • View Profile
Re: How to keep diagram with preceding package name in report?
« Reply #2 on: August 06, 2018, 05:00:28 pm »
We use a word macro to
- shrink the images to the correct size so the title
- set certain styles "keep with next"

Geert
Yes, that seems like a work around. It is definitely a bug in EA though. Any chance of sharing that macro code?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9399
  • Karma: +260/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to keep diagram with preceding package name in report?
« Reply #3 on: August 06, 2018, 05:05:21 pm »
This is the code for setting the keep with next on some styles:

Code: [Select]
Sub setStyles()
    Dim currentStyle As style
    Set currentStyle = ActiveDocument.Styles.Item("Heading 1")
    currentStyle.ParagraphFormat.KeepWithNext = True
    Set currentStyle = ActiveDocument.Styles.Item("Heading 2")
    currentStyle.ParagraphFormat.KeepWithNext = True
    Set currentStyle = ActiveDocument.Styles.Item("Heading 3")
    currentStyle.ParagraphFormat.KeepWithNext = True
    Set currentStyle = ActiveDocument.Styles.Item("Heading 4")
    currentStyle.ParagraphFormat.KeepWithNext = True
    Set currentStyle = ActiveDocument.Styles.Item("Diagram Image")
    currentStyle.ParagraphFormat.KeepWithNext = True
End Sub

This one resizes images:

Code: [Select]
Sub ResizeAllImages()

Dim oILShp As InlineShape

For Each oILShp In ActiveDocument.InlineShapes
    If oILShp.Height > CentimetersToPoints(23) Then
        oILShp.Width = ((CSng(oILShp.Height) / CentimetersToPoints(23)) * CSng(oILShp.Width))
        oILShp.Height = CentimetersToPoints(23)
    End If
Next
End Sub

And this one sets the rows to allow to break across pages (useful for tables with large amounts of text)

Code: [Select]
Sub SetTableProperties()
    On Error Resume Next
    Dim oTbl As Table
    Dim oRow As row
    Dim headerRow As row
    For Each oTbl In ActiveDocument.Tables
        Set headerRow = oTbl.Rows(1)
        If headerRow.HeadingFormat Then
            For Each oRow In oTbl.Rows
                oRow.AllowBreakAcrossPages = False
            Next
        End If
    Next
End Sub

Geert


michielper

  • EA User
  • **
  • Posts: 120
  • Karma: +1/-0
    • View Profile
Re: How to keep diagram with preceding package name in report?
« Reply #4 on: August 06, 2018, 05:13:11 pm »
Thanks Geert!