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 Automation :- Table Autoformat Method
Topic Summary: Auto format existing tables using OLE Automation
Created On: 27-Jul-2005 16:53
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.
 27-Jul-2005 16:53
User is offline View Users Profile Print this message


David McMahon

Posts: 16
Joined: 15-Apr-2005

I am trrying to format an existing  Word Table using OLE Automation from DXL,

(The syntax in VBA is :- expression.AutoFormat(Format, ApplyBorders, ApplyShading, ApplyFont, ApplyColor, ApplyHeadingRows, ApplyLastRow, ApplyFirstColumn, ApplyLastColumn, AutoFit)

I  have translated the above into a function (see below):-

bool applyTableFormat (string str_Table,str_FormatStyle,OleAutoObj &objWord){
OleAutoObj objDocs = null
OleAutoObj objDoc = null
OleAutoObj objTables = null

OleAutoObj objSelection = null
OleAutoObj objTable = null

OleAutoObj objRange = null
OleAutoArgs args   = create

 if(!noerror(oleGet(objWord,"Documents", objDocs))) return falseOnError("")
 if(nullOLEobj(objDocs, "Unable to get Documents collection")) return falseOnError("")

 clear(args)
 put(args, 1)
 if(!noerror(oleMethod(objDocs, "Item", args, objDoc))) return falseOnError("")
 if(nullOLEobj(objDoc, "Unable to get Document 1")) return falseOnError("")

//Table collection
 if(!noerror(oleGet(objDoc,"Tables", objTables))) return falseOnError("")
 if(nullOLEobj(objTables, "Unable to get Tables collection")) return falseOnError("")

//Table Object
 clear(args)
 put(args, str_Table)
 if(!noerror(oleMethod(objTables, "Item", args, objTable))) return falseOnError("")
 if(nullOLEobj(objTable, "Unable to get Table")) return falseOnError("")

 clear(args)
 put(args, "Format", str_FormatStyle)
 if(!noerror(oleMethod(objTable,"AutoFormat",args))) return falseOnError("")

return true
}

To apply the wdTableFormatContemporary format to table 1  I used:-
applyTableFormat ("1","wdTableFormatContemporary",objWord)
 
...nothing happens... any ideas??



Report this to a Moderator Report this to a Moderator
 27-Jul-2005 20:51
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

quote:

Originally posted by: David McMahon
//Table Object
 clear(args)
 put(args, str_Table)
 if(!noerror(oleMethod(objTables, "Item", args, objTable))) return falseOnError("")
 if(nullOLEobj(objTable, "Unable to get Table")) return falseOnError("")



clear(args)
put(args, "Format", str_FormatStyle)
if(!noerror(oleMethod(objTable,"AutoFormat",args))) return falseOnError("")



My first guess is that str_Table should be an integer value. Try to hardcode the table selection as put(args, 1) and see if that works.

I looked around in the Word VBA documentation and didn't immediately see a list of values for the Format Variant.

I've been succesful turning on autofit for a table using the following snippet of code:


const int wdAutoFitFixed = 0
const int wdAutoFitContent = 1
const int wdAutoFitWindow = 2

clear args
put(args, wdAutoFitContent)
oleMethod(objTable, "AutoFitBehavior", args)


Good luck,
Dennis
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.