Poor Skip.
Peter: "It may be helpful to other members of this forum. I am sure the 27 lines mentioned above would alos be helpful. Any chance of sharing this , please Gerry /fumei?"
Yes I could, but you have to answer what has already been asked of you. Some more details. I do not even know a basic starting point for you. Are you working in Excel, or are you working in Word? In other words....
a) In Excel: getting stuff from the open Excel file and putting into an existing Word doc (which may - or may not - be open);
b) In Word: GOING and getting stuff from Excel (which may - or may not - be open), and putting it into the open Word document.
The code below uses example a) - from Excel, with the document NOT open. So it has to be opened.
Code:
Option Explicit
Sub Yadda()
Dim appWord As Word.Application
Dim aDoc As Word.Document
Dim oTable As Word.Table
Dim MyArray()
Dim j As Long
Dim var
For var = 0 To 99 ' makes the array
ReDim Preserve MyArray(var)
MyArray(var) = j
j = j + 1
Next
Set appWord = CreateObject("Word.Application")
Set aDoc = appWord.Documents.Open _
(Filename:="c:\testarray3.doc")
Set oTable = aDoc.Bookmarks("MyTable").Range.Tables(1)
j = 1
For var = 0 To UBound(MyArray())
oTable.Range.Cells(j).Range.Text = MyArray(var)
j = j + 1
Next
aDoc.Save
aDoc.Close
Set aDoc = Nothing
appWord.Quit
Set appWord = Nothing
End Sub
It is VERY important that you properly close and destroy instances of applications and their files...and in the proper order.
In the example above, the Word instance is created, the existing document opened, the existing table filled with the array, the document saved, the document closed, the document object destroyed, the Word instance Quit, and the Word instance destroyed...
all without ever seeing Word. Everything happens in the background.
Who knows if this is close to what you want to do. Note also that the code above uses early-binding, so you need a Reference.
"A little piece of heaven
without that awkward dying part."
advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)
Gerry