Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I export a Pivot Table in Excel into Word? bananagirl Excel Worksheet Functions 0 May 24th 10 02:27 PM
export from excel to word lermar New Users to Excel 3 November 9th 08 02:41 PM
Export from Excel to Word kath0178 New Users to Excel 2 September 13th 06 05:30 PM
Export Excel to Word No Name Excel Programming 2 February 27th 04 07:31 PM
vb code to export data into existing Access table desperate Excel Programming 2 November 19th 03 05:05 PM


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"