Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
code to export excel table to word
I have created in Excel a number of automated tables on separate worksheets
and would like to export these tables to Word through use of a macro. The tables all have similar formats (i.e. headings and width) but can vary in length. So far I have succeeded in placing them in Word but cannot automatically insert page breaks between each table, which is key for this particular project. I am working in VBA in Excel in order to create this Word application. I'm fairly certain that the code will not accept any reference to "Selection" (e.g. table, paragraph, etc.). Any ideas on how to insert these page breaks? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
code to export excel table to word
Hello to insert Pages Break in Word document , you may try WordDoc.Content.InsertBreak Type:=wdSectionBreakNextPage Regards miche -- michelxl ----------------------------------------------------------------------- michelxld's Profile: http://www.excelforum.com/member.php...fo&userid=1736 View this thread: http://www.excelforum.com/showthread.php?threadid=38987 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
code to export excel table to word
This line of code returns an error saying the parameter value is not in the
acceptable range. Since the only content in the document itself is just several tables, the program only assumes that there is one paragraph (although there is also insertparagraph commands within the code) so it cannot distinguish between sections between tables. "michelxld" wrote: Hello to insert Pages Break in Word document , you may try WordDoc.Content.InsertBreak Type:=wdSectionBreakNextPage 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
code to export excel table to word
Hello this macro copy excel tables ( named Tableau1 , Tableau2 ...) in a ne 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 miche -- michelxl ----------------------------------------------------------------------- michelxld's Profile: http://www.excelforum.com/member.php...fo&userid=1736 View this thread: http://www.excelforum.com/showthread.php?threadid=38987 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I export a Pivot Table in Excel into Word? | Excel Worksheet Functions | |||
export from excel to word | New Users to Excel | |||
Export from Excel to Word | New Users to Excel | |||
Export Excel to Word | Excel Programming | |||
vb code to export data into existing Access table | Excel Programming |