View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish[_2_] Debra Dalgleish[_2_] is offline
external usenet poster
 
Posts: 52
Default Exporting to Word

You could find the address of the bottom right cell of the chart, then
copy and paste a picture of the range. For example:

Dim strCell As String
strCell = ActiveSheet.ChartObjects("Chart 138").BottomRightCell.Address
..
..
With ActiveSheet
Range(Range("A9"), Range(strCell)).CopyPicture _
Appearance:=xlScreen, Format:=xlBitmap


Michael wrote:
Hi Guys,


I have a macro that copies a range in excel and exports it
to word. My problem is won't copy the linked chart when I
select the used range. How do I write a routine that will
copy both the range and chart and insert them both into
word. Also I have found that it will also not paste
special as a bitmap, only as an excel worksheet.

I attach code below which I have edited from a previously
answer post in this newsgroup

Thanks for your help

Michael

Private Sub CommandButton2_Click()
Worksheets("calculations").Select
Application.CutCopyMode = xlCopy
Application.DisplayAlerts = False
On Error Resume Next
Dim rng As Range
With ActiveSheet
Range(Range("A9"), ActiveCell.SpecialCells
(xlLastCell)).Copy
.ChartObjects("Chart 138").Activate
.ChartArea.Select
.ChartArea.Copy
Dim APPWD As Object
Dim i As Integer
Set APPWD = CreateObject("Word.Application")
APPWD.Visible = True
APPWD.ChangeFileOpenDirectory ActiveWorkbook.path
APPWD.Documents.Open Filename:="NewCashflow.doc",
ConfirmConversions:=False, ReadOnly:=True
APPWD.Selection.PasteSpecial Link:=False,
DataType:=wdPasteBitmap, _

Placement:=wdFloatOverText, DisplayAsIcon:=False
Application.DisplayAlerts = True

End With
End Sub



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html