Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
sivarajs
Specialist II
Specialist II

Issue in pasting multiple table objects in word

Hi,

Am exporting multiple table object to a single word document. But in the output word document i can see all the tables merged together.How can i give space between the tables?. here is my code

Sub export_word

set objWord = CreateObject("Word.Application")

objWord.visible = false

set objDoc=objWord.Documents.add

Const wdOrientLandscape = 0

objDoc.PageSetup.Orientation = wdOrientLandscape

ActiveDocument.GetSheetObject("CH02").CopyTableToClipboard true

objWord.Selection.Paste

ActiveDocument.GetSheetObject("CH04").CopyTableToClipboard true

objWord.Selection.Paste

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

objWord.Selection.Paste

'objDoc.SaveAs "C:\Report"

objWord.quit

end sub

Regrads,

Sivaraj

3 Replies
petter
Partner - Champion III
Partner - Champion III

You can simply insert the following VBScript statement between every table .Paste in your macro:

objWord.Selection.TypeText Chr(12)

Chr(12) is ASCII 12 - which is Form Feed that it equivalent to PageBreak in Word. So each new table will land on a new page which I presume you want.

If not you can simply use Chr(13) & Chr(10) ....

sivarajs
Specialist II
Specialist II
Author

I have used objeselction.typetext chr(11) to get space. Your idea is very useful for me. I can use it.

petter
Partner - Champion III
Partner - Champion III

You are welcome. If this answers your question please mark the question as answered so the topic doesn't stay open.