Q

Adjust Microsoft Word table width via LotusScript

I've been struggling to solve this problem for days but still do not have a workaround. I need to adjust the Microsoft Word table width via LotusScript.

Here is the script:

 Set wrdApp = CreateObject
("Word.Application")
 wrdApp.documents.add
(xtempDrive$+"mydoc.doc") 
 
 wrdApp.Visible = True
 
 ' Add a new document
 
 Set wrddoc = 
wrdapp.Application.ActiveDocument
 
 Set wrdSelection = wrdApp.Selection
  Set range = wrdSelection.range
 Set tables = wrdApp.Selection.tables.add
(range, 1,7)
 
 Dim wdAdjustProportional As Integer
 Dim wdAdjustNone As Integer
 Dim wdAdjustFirstColumn As Integer
  
 wdAdjustProportional = 1
 wdAdjustNone = 0
 wdAdjustFirstColumn = 2
 
 wrdDoc.Tables(1).Columns(1).
SetWidth 1.18, wdAdjustProportional
 wrdDoc.Tables(1).Columns(2).
SetWidth 0.02, wdAdjustProportional
 wrdDoc.Tables(1).Columns(3).
SetWidth 2.5, wdAdjustProportional
 wrdDoc.Tables(1).Columns(4).
SetWidth  "0,02", wdAdjustProportional
 wrdDoc.Tables(1).Columns(5).
SetWidth "1,3", wdAdjustProportional
 wrdDoc.Tables(1).Columns(6).
SetWidth "0,02", wdAdjustProportional
 wrdDoc.Tables(1).Columns(7).
SetWidth "1,12", wdAdjustProportional
 wrdDoc.Tables(1).Rows.Alignment 1
' wrdDoc.Tables(1).Rows.SetLeftIndent -21.6 
 

But LotusScript gives me this error, "Value out of range" when it hits the first "wrdDoc.Tables(x).Columns(x).SetWidth "xxxx", wdAdjustProportional."

Which is incorrect? Thank you very much.

I can't test this in my current situation. In the code I have seen, the table's variable isn't subscripted and the width is usually set with InchesToPoints. Try wrdDoc.Tables.Columns(x).Width = wrdDoc.InchesToPoints(xx). The figures in InchesToPoints are not quoted. Here is some sample code.

I would also check the Microsoft sites and forums.

Do you have comments on this Ask the Expert question and response? Let us know.

This was first published in October 2004

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close