ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting a Range to Word (https://www.excelbanter.com/excel-programming/288725-pasting-range-word.html)

Ian Mangelsdorf

Pasting a Range to Word
 
Hi all

I have a sub written (see below) to copy a range of data from Excel
and paste it into the active word document. All works fine with other
versions I have written but now I am copying a Landscape a4 page to
word (also landscape a4).

I want to copy a1 to ah15 as is set in page1. however when I paste
this it only copies to ag15. Have I declared or set something wrong in
this code.



Cheers

Ian

Sub Report_Description_Data()

Dim WDApp As Word.Application
Dim WDDoc As Word.Document

Dim ws As Worksheet
Set ws = Worksheets("description")
Set Rng = ws.Range("a12:ah" & ws.Range("a12").End(xlDown).Row)
Set page1 = ws.Range(Cells(1, 1), Cells(15, 44))



sample_no = Rng.Rows.Count
Total_pages = (sample_no - 29) \ 20 + 2
' Reference Word XP
Set WDApp = GetObject(, "Word.Application.10")
' Reference active document
Set WDDoc = WDApp.ActiveDocument


page1.CopyPicture Appearance:=xlPrinter, Format:=xlPicture

WDApp.Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False

end sub


All times are GMT +1. The time now is 03:32 AM.

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