View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Smallweed Smallweed is offline
external usenet poster
 
Posts: 133
Default Export data from excel into an existing word document


In Excel VB Editor, click on Tools, References and tick M/soft Word Objects.
Then use following:

Sub WriteToWord()
Dim objWord As New Word.Application
Dim objDoc As Word.Document

Set objDoc = objWord.Documents.Add("letter.dot") 'miss out brackets and
template name if just want to add normal document

With objWord

(in Word, use macro recorder to record steps to paste special Excel data
then copy and paste these steps in here with a full stop in front of each)

End With
objWord.Visible = True 'default is to keep Word invisible

Set objDoc = Nothing
Set objWord = Nothing
End Sub


"CJJ" wrote:

Hi,
I'm looking to export several tables from excel into an existing word
document using VBA. I know how to create a new word document and insert data
into it using hardcoding however i don't know how to open a word document and
actually export tables created in excel. If anyone could point me in the
right direction I would really appreciate it!

Cheers