Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Create a Word Table from a Excel Macro

Hello Everybody

I'm really new at using macros (a week or so..) and i am having a few
problems creating word tables.
What i want to do is : create a word document, copy text from a cell
in a excel worksheet into a paragraph in the word document and then
copy other cells into a table in the word document.

The table is created just fine, but when i try to insert more text
outside the table i wont let me.
Everything is inserted into the first cell of my word table...

Any idea why is this happening? =(

Thanks in advance!




Sub CreateNewTable()
Dim docActive As Document
Dim tblNew As Table
Dim celTable As Cell
Dim intCount As Integer

'Create word document
Set docActive = CreateObject("Word.Document")

'Create word table
Set tblNew = docActive.Tables.Add( _
Range:=docActive.Range(Start:=0, End:=0), NumRows:=3, _
NumColumns:=4)
intCount = 1

'Fill the cells in the table
For Each celTable In tblNew.Range.Cells
celTable.Range.InsertAfter "Cell " & intCount 'or the
..values from my excel..
intCount = intCount + 1
Next celTable

tblNew.AutoFormat ApplyBorders:=True, ApplyFont:=True,
ApplyColor:=True


'I want this followint text to be a new paragraph after the table
but instead it is inserted inside the Table =(

With docActive.ActiveWindow.Selection

.TypeParagraph
.Font.Name = "Arial"
.Font.Size = "22"
.Font.Color = RGB(64, 128, 192)
.TypeText Text:="Cell Comments In Workbook: " + ActiveWorkbook.Name
.TypeParagraph

End With

End Sub

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
consolidation of tables in excel with text and figures samenvoegen van sheets Excel Worksheet Functions 8 March 2nd 06 04:27 PM
Copy from WORD to EXCEL using a macro..... Tee Excel Discussion (Misc queries) 1 March 1st 06 07:46 PM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 04:56 AM
Excel macro that opens new MS Word file and pastes data as a pictu Rob Excel Worksheet Functions 0 July 6th 05 05:12 PM
How do I create a macro, that references another excel file ??? Aries Excel Worksheet Functions 1 May 25th 05 11:37 AM


All times are GMT +1. The time now is 10:12 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"