Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Coping data from excel to word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oggy - 14 Apr 2007 21:35 GMT
Hi

I am writing a macro in excel to copy data from a cell and put it in
a
new word document. I have managed this OK, but i am struggling to
find
a code that copies a group of cells together, IE  all the data in
cells G10:L2000

Has anyone got any suggestions for me?

Thanks

Oggy
Nick Hodge - 15 Apr 2007 09:09 GMT
Oggy

This uses early binding so you will need to set a  reference in advance to
the Microsoft Word x library (where x is the version) through the VBE
(Tools>References...). Once you finish your code and maybe save an quit
word, take the object variables and 'set' them to nothing in reverse order

Set wdSelect=Nothing
..........

Here is the code

Sub PasteToWord()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdSelect As Word.Selection

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add
Set wdSelect = wdDoc.ActiveWindow.Selection
wdApp.Visible = True

Worksheets("Sheet1").Range("G10:L2000").Copy
wdSelect.PasteExcelTable False, False, False
End Sub

Signature

HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT@zen.co.ukANDTHIS
web: www.nickhodge.co.uk
blog: www.nickhodge.co.uk/blog/

FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk

> Hi
>
[quoted text clipped - 10 lines]
>
> Oggy

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.