Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation - Word2002 vs. Word97
Message
From
08/11/2002 14:01:07
 
 
To
08/11/2002 09:05:40
Patrick O'Neil
American Specialty Information Services
Roanoke, Indiana, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00716139
Message ID:
00720447
Views:
11
I guess I didn't word my question well enough. I know what a range object is and what it represents. What I wanted to know was what your range object is. Probably I just missed it somewhere along the line.

Anyway, there doesn't seem to be a good way to center a table in VBA code (at least, not that I could find), but what you can do is to add a Frame, then add the table to the frame instead of directly into the document. You can then center the frame. Still not real straightforward, but doable.
oWord = CreateObject('Word.Application')
oDoc = oWord.Documents.Add
oDoc.Paragraphs.Add    && just for the heck of it
oRange = oDoc.Paragraphs(2).Range   && get the range
oFrame = oDoc.Frames.Add(oRange)    && add a frame
oTable = oDoc.Tables.Add(oFrame.Range,4,3)   && add a 4 row, 3 col table to the frame
* set some column widths - default for frame is to auto resize
oTable.Columns(1).Width = 60
oTable.Columns(2).Width = 60
oTable.Columns(3).Width = 60
oFrame.WidthRule= 2  && wdFrameExact
lnWidth = 0
For lnCount = 1 to oTable.Columns.Count
   lnWidth = lnWidth + oTable.Columns(lnCount).Width
EndFor
oFrame.Width = lnWidth
oFrame.HorizontalPosition= ;
   (oDoc.PageSetup.pagewidth-oDoc.PageSetup.LeftMargin - ;
     oDoc.PageSetup.RightMargin - oFrame.Width)/2
Alan

>>>What is the oRange object - how is it created?
>>>
>>
>
>didn't actually answer your question. you create a range object
>within the document by specifying a beginning point and a length
>or ending point. there are a zillion ways of specifying the
>begin and end. like range is from word(13) to word(57).
>or range is from line(19) to end-of-document. etc etc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform