ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Export data from excel into an existing word document (https://www.excelbanter.com/excel-programming/430798-export-data-excel-into-existing-word-document.html)

CJJ[_2_]

Export data from excel into an existing word document
 
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



Smallweed

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



ryguy7272

Export data from excel into an existing word document
 

This may help:
http://word.mvps.org/faqs/InterDev/C...WordFromXL.htm

Also:
http://www.mrexcel.com/articles/excel-to-word-macro.php
The second link may be more helpful in this scenario.

One more, just for fun:
http://www.erlandsendata.no/english/...olecontrolword


HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Smallweed" wrote:

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




All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com