ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting to Word (https://www.excelbanter.com/excel-programming/277970-re-exporting-word.html)

Debra Dalgleish[_2_]

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



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

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