Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 74
Default Excel Range In Word

I wish to paste a named range from Excel into a Word Document using VBA.
From Excel I have created a Word document as an object, but cannot
understand how to use any of the Word VBA code I have recorded.

In Excel I can easily reference the named range I require to insert, but how
I utilise this to paste it into the Word document I have created has me
scratcjing my head.

Recording the paste operation in Word gives:

Selection.PasteExcelTable False, False, False

All I am trying to to is paste a number of Excel ranges into a Word
document, does anyone have any code whioch might help me.

PWS









  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 13
Default Excel Range In Word

So, if you take your recorded code and qualify it with te Word object ...

(YourWordObject).Selection.etc

what happens?

--
Enjoy,
Tony

"Paul W Smith" wrote in message
...
I wish to paste a named range from Excel into a Word Document using VBA.
From Excel I have created a Word document as an object, but cannot
understand how to use any of the Word VBA code I have recorded.

In Excel I can easily reference the named range I require to insert, but
how I utilise this to paste it into the Word document I have created has
me scratcjing my head.

Recording the paste operation in Word gives:

Selection.PasteExcelTable False, False, False

All I am trying to to is paste a number of Excel ranges into a Word
document, does anyone have any code whioch might help me.

PWS










  #3   Report Post  
Posted to microsoft.public.excel.programming, microsoft.public.word.vba.general
external usenet poster
 
Posts: 220
Default Excel Range In Word

Paul,

Try this:

Sub CopyToWord()
'must have a reference to the word object library
Dim wdApp As Word.Application
Dim ws As Worksheet
Dim wdDoc As Word.Document
Set wdApp = CreateObject("Word.application")
Set wdDoc = wdApp.Documents.Add

For i = 1 To Names.Count
ActiveSheet.Range(Names(i)).Copy
wdDoc.Paragraphs(wdDoc.Paragraphs.Count) _
.Range.InsertParagraphAfter
wdDoc.Paragraphs(wdDoc.Paragraphs.Count) _
.Range.Paste
Next i

wdApp.ActiveDocument.Save
wdDoc.Close
Set wdDoc = Nothing
wdApp.Quit
Set wdApp = Nothing
End Sub

--
Dan


On Dec 17, 2:23 pm, "Paul W Smith" wrote:
I wish to paste a named range from Excel into a Word Document using VBA.
From Excel I have created a Word document as an object, but cannot
understand how to use any of the Word VBA code I have recorded.

In Excel I can easily reference the named range I require to insert, but how
I utilise this to paste it into the Word document I have created has me
scratcjing my head.

Recording the paste operation in Word gives:

Selection.PasteExcelTable False, False, False

All I am trying to to is paste a number of Excel ranges into a Word
document, does anyone have any code whioch might help me.

PWS


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
pasting excel range into a Word doc Peter V[_2_] Excel Programming 3 January 17th 07 05:41 PM
How can I save a Range in Excel to a Word File? Martin Fishlock Excel Programming 0 January 5th 07 07:38 AM
Can't Dim Range when Controlling Word from Excel T_o_n_y Excel Programming 2 July 29th 06 11:56 PM
Inserting Excel Range into Word cmurphy Excel Programming 2 July 11th 05 07:30 PM
Getting a range from Excel into a Word document daniB[_6_] Excel Programming 0 February 12th 04 02:40 PM


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