Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.tables
Tasin
 
Posts: n/a
Default How to add multiple tables via vbscript?

Hi,

I'm trying to create a multi-table doc via a vbscript, with some text
between each table (a title effectively). The script I've come up with adds
each of the items, but just overwrites the previous item. ie adds the first
title, then overwrites with a table, then overwrites that with the next title
and so on.

I think I'm missing something pretty simple, just to move the selction on,
but as usual, it's the simple thing that's proving to be the hardest. My
script is listed below for anyone who can help me

Thanks.


Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.EndKey wdStory, wdMove

'define table section, including title
objSelection.Font.Size = "12"
objSelection.TypeParagraph()
objSelection.TypeText "title 1"
objSelection.TypeParagraph()
objSelection.EndKey wdStory, wdMove

Set objRange = objDoc.Range()
objDoc.Tables.Add objRange, 1,3
Set objTable = objDoc.Tables(1)
objTable.AutoFormat(16)

Set objSelection = objWord.Selection
objSelection.EndKey wdStory, wdMove

'define table section, including title
objSelection.Font.Size = "12"
objSelection.TypeParagraph()
objSelection.TypeText "title2"
objSelection.TypeParagraph()
objSelection.EndKey wdStory, wdMove

Set objRange = objDoc.Range()
objDoc.Tables.Add objRange, 1, 4
Set objTable = objDoc.Tables(2)
objTable.AutoFormat(6)

 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete multiple tables? Á÷À˵ÄË«Óã Tables 7 March 22nd 06 12:43 PM
Tables setting multiple section breaks with multiple headers [email protected] Tables 1 January 19th 06 10:05 AM
Create multiple stacked tables in word using vb.net Jenny Beavers Tables 2 January 17th 06 03:12 PM
Changing format of multiple pre-created tables Wendy Microsoft Word Help 2 September 14th 05 08:55 AM
mailmerging multiple tables from access in one word-document: how? svdh Mailmerge 2 December 15th 04 02:32 PM


All times are GMT +1. The time now is 05:35 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"