View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
mcope mcope is offline
external usenet poster
 
Posts: 3
Default code to export excel table to word

Thanks for the help so far Michel, but the .InsertBreak command does not seem
to be working in this particular application. I've also tried to send
command keys (Ctrl + Enter) to Word in order to insert a page break but since
I'm working from Excel, the macro does not want to accept that I'd want to
send those key combinations to the Word application even though defined. Are
there any other alternatives out there that I can try? This may just be a
lost cause.

"michelxld" wrote:


Hello

this macro copy excel tables ( named Tableau1 , Tableau2 ...) in a new
Word document , and insert page break between each table


Sub EnvoyerTableauxExcelVersWord()
'activate Microsoft Word xx.x Object Library
Dim AppWord As Word.Application
Dim i As Byte

Set AppWord = New Word.Application
AppWord.Visible = True
AppWord.Documents.Add

For i = 1 To 4 'table number
'each table is named "Tableau1" , "Tableau2" ....

Range("Tableau" & i).Copy

With AppWord.Selection
.Paste
.InsertBreak Type:=wdSectionBreakNextPage 'page break
End With

Next i

Application.CutCopyMode = False
End Sub


Regards
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=389879