T
Tasin
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)
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)