I
Ian Mangelsdorf
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
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