Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: OLE Sizing When Exported to Word
Topic Summary:
Created On: 5-Jan-2004 22:39
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 5-Jan-2004 22:39
User is offline View Users Profile Print this message


Robert Padilla

Posts: 13
Joined: 5-Jan-2004

We have embedded Visio and PowerPoint OLE objects in modules. We have automation in place, scheduled tasks, that daily publish Word and HTML documents from DOORS modules to a server directory for web access. The problem... Most of the Visio and PowerPoint OLE objects are larger than the standard 8.5X11 page (Word - With HTML, this isn't a problem).

I've been fighting with the Word script to determine the size of an OLE object and reformat, if necessary, to no larger than 6.5" wide when exported.

Has anyone had to do this? Looking for assistance with OLE automation to handle this.

Thanks!
-=[ Bob Padilla ]=-

Report this to a Moderator Report this to a Moderator
 6-Jan-2004 12:09
User is offline View Users Profile Print this message


Pieter DE WAARD

Posts: 73
Joined: 11-Jul-2003

Bob,

We have similar problems. See my earlier posting. The OLE-object does not size automatically when exported to DOORS (we work in DOORS 5.2). Is there anyone out there that has found a solution to this problem? BTW, we checked: the same problem persists in DOORS 7 SR1, although the OLE object behaves differently when edited from DOORS.

Pieter de Waard
NHIndustries

-------------------------
Pieter de Waard
www.nhindustries.com
Report this to a Moderator Report this to a Moderator
 20-Apr-2004 15:13
User is offline View Users Profile Print this message


Anton Drexler

Posts: 25
Joined: 9-Dec-2003

Hi Bob, hi Pieter,

we had the same problem (as anybody will have, I think ...).

The solution I choose to fight it was to write a Word Macro which loops through all OLE objects in a word document and resizes them (in correct scale) so that they fit on a A4 page. This macro is called by the DXL word export script after the module content is exported completely, so after export all exported OLE objects are resized automatically.

This is the macro:


Sub resizeAllShapes()
'
' resizeAllShapes Makro
' Makro aufgezeichnet am 11.06.03 von Anton S. Drexler
'
For Each embeddedForm In ActiveDocument.InlineShapes

Wd = embeddedForm.Width
Ht = embeddedForm.Height

Rt = Ht / Wd
Ht = 524.4 * Rt

If embeddedForm.Width > 525 Then
embeddedForm.LockAspectRatio = msoTrue
embeddedForm.Width = 524.4
embeddedForm.Height = Ht
End If

Rt = Ht / Wd
Wd = 651.95 / Rt

If embeddedForm.Height > 652 Then
embeddedForm.LockAspectRatio = msoTrue
embeddedForm.Width = Wd
embeddedForm.Height = 651.95
End If
Next embeddedForm
End Sub


Explanation to the numbers:
524.4 is the maximal usable width of the page in points (= 18.5 cm)
651,95 is the maximal usable height of the page in points (= 23.0 cm)
where 1 cm = 28,35 points

The usable width is determined by the paragraph style you are using,
i.e. calculated as the the difference between left and right margins.
The usable height is determined by the top and bottom margins you
use in your word document.


The macro is used in DXL by the DXL function:

void correctFigureSize () {
clear objArgBlock
put (objArgBlock, "MacroName", "resizeAllShapes")
checkRes (oleMethod (objWord, "Run", objArgBlock))
}

which is called after completion of the export.


Try it and give me feedback!

Toni Drexler
Consultant for Quality Management and Requirement Management
a.s.drexler@gmx.de
(at the moment at Eurocopter Germany)
Report this to a Moderator Report this to a Moderator
 20-Apr-2004 16:31
User is offline View Users Profile Print this message


Pieter DE WAARD

Posts: 73
Joined: 11-Jul-2003

Toni,

Thanks for sharing this macro. Will give it a go (when we find the time ...).

Pieter

-------------------------
Pieter de Waard
www.nhindustries.com
Report this to a Moderator Report this to a Moderator
 21-Apr-2004 17:10
User is offline View Users Profile Print this message


Jonathan Marshall

Posts: 27
Joined: 10-Apr-2003

Toni,

I like the idea and it worked OK but its difficult to make sure users have a copy of the macro as well as the export script. An alternative method is to code the whole thing in DXL which can then be part of the export script. The following routine can be called at the end of the export.


void wordResizeAllShapes() {

// Resize shapes if they don't fit on an A4 Portrait page

OleAutoObj objInlineShapes = null
OleAutoObj objShape = null
int nShapes

vbaCheckRes(oleGet(objDoc, "InlineShapes", objInlineShapes))
vbaCheckRes(oleGet(objInlineShapes, "Count", nShapes))

int i
for (i = 1; i <= nShapes; i++) {

clear objArgBlock
put(objArgBlock,i)
vbaCheckRes(oleMethod(objInlineShapes, "Item", objArgBlock, objShape))

int wd0
int ht0
real rt

vbaCheckRes(oleGet(objShape, "Width", wd0))
vbaCheckRes(oleGet(objShape, "Height", ht0))

rt = realOf(ht0) / realOf(wd0)
int ht = intOf(445.1 * rt)
int wd

if (wd0 >= 446) {
vbaCheckRes(olePut(objShape, "LockAspectRatio", -1))
wd = 445
vbaCheckRes(olePut(objShape, "Width", wd))
vbaCheckRes(olePut(objShape, "Height", ht))
} else {
wd = wd0
ht = ht0
}

rt = realOf(ht) / realOf(wd)
wd = intOf(595.35 / rt)

if (ht >= 596) {
vbaCheckRes(olePut(objShape, "LockAspectRatio", -1))
ht = 595
vbaCheckRes(olePut(objShape, "Width", wd))
vbaCheckRes(olePut(objShape, "Height", ht))
}
}

closeIfNonNull objShape
closeIfNonNull objInlineShapes

}

Jon


NB I changed your numbers a bit to fit my page

-------------------------
Jonathan Marshall
EADS Astrium
Report this to a Moderator Report this to a Moderator
 23-Apr-2004 10:34
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Anyone want another solution? I export to RTF rather than Word, mainly because that means I can do some extra things like adding headers, footers, default opening pages and styles from a second specially formatted formal module. I check the size of the OLE objects in RTF form while they're still in DOORS, so all my processing is done in DXL. That way I don't have to run Word macros at all, so the export is significantly quicker than writing to Word using automation.

The bit that does the resizing is given below. Note that this is a section of a bigger DXL script file, so some of it might note make sense -- I think I've got most of it in there though...

PS If this is bad code, could somebody let me know before I go creating bucket-loads more of the stuff? Ta

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive

Edited: 23-Apr-2004 at 10:35 by Paul Tiplady
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.