Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Copy and Paste Charts as Picture in Different Workbook

Here is my code... everything working except copying and pasting the charts
as picture... no error, the picture of the excel chart just doesn't show up.
thanks for any help. SteveC

Sub test copy excel charts

'code here, then:


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy

With ThisWorkbook.Sheets(ShName).Range("A1")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteColumnWidths, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot
List.xls").Sheets("SnapShot").Shapes.Range(Array(" CIQChart1s0t0",
"CIQChart1s1t0")).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

With ThisWorkbook.Sheets(ShName).Range("c48")
.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False _
, DisplayAsIcon:=False


End With

Application.CutCopyMode = False

'more code

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Copy and Paste Charts as Picture in Different Workbook

Better yet, how to select every single chart (not objects, no buttons) in a
worksheet, and paste in a different sheet of a different workbook -- in the
same place where the charts were located on the original sheet... many thanks

"SteveC" wrote:

Here is my code... everything working except copying and pasting the charts
as picture... no error, the picture of the excel chart just doesn't show up.
thanks for any help. SteveC

Sub test copy excel charts

'code here, then:


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy

With ThisWorkbook.Sheets(ShName).Range("A1")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteColumnWidths, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot
List.xls").Sheets("SnapShot").Shapes.Range(Array(" CIQChart1s0t0",
"CIQChart1s1t0")).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

With ThisWorkbook.Sheets(ShName).Range("c48")
.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False _
, DisplayAsIcon:=False


End With

Application.CutCopyMode = False

'more code

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Copy and Paste Charts as Picture in Different Workbook

Sub test()
Dim nPicCnt As Long
Dim chtObj As ChartObject
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim pic As Picture

Set wsSource = Workbooks("Book2").Worksheets("Sheet1")
Set wsDest = Workbooks("Book3").Worksheets("Sheet1")

nPicCnt = wsDest.Pictures.Count

For i = 1 To wsSource.ChartObjects.Count
Set chtObj = wsSource.ChartObjects(i)

chtObj.CopyPicture Appearance:=xlScreen, Format:=xlPicture

wsDest.Paste

nPicCnt = nPicCnt + 1
With wsDest.Pictures(nPicCnt)
.Left = chtObj.Left
.Top = chtObj.Top
End With
Next

End Sub

FWIW, if intention is to backup charts could copy/paste the actual charts
then break links to the original workbook. This would lead to smaller file
size, and retain the original data in the new workbook and without need to
replace data in cells in the new workbook. If interested I have an app in
development that does that.

Regards,
Peter T
pmbthornton gmail com

"SteveC" wrote in message
...
Better yet, how to select every single chart (not objects, no buttons) in

a
worksheet, and paste in a different sheet of a different workbook -- in

the
same place where the charts were located on the original sheet... many

thanks

"SteveC" wrote:

Here is my code... everything working except copying and pasting the

charts
as picture... no error, the picture of the excel chart just doesn't show

up.
thanks for any help. SteveC

Sub test copy excel charts

'code here, then:


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy

With ThisWorkbook.Sheets(ShName).Range("A1")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteFormats, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot List.xls").Sheets("Snapshot").Cells.Copy
.PasteSpecial _
Paste:=xlPasteColumnWidths, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False


Workbooks("Hot
List.xls").Sheets("SnapShot").Shapes.Range(Array(" CIQChart1s0t0",
"CIQChart1s1t0")).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

With ThisWorkbook.Sheets(ShName).Range("c48")
.PasteSpecial Format:="Picture (Enhanced Metafile)", Link:=False _
, DisplayAsIcon:=False


End With

Application.CutCopyMode = False

'more code

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Copy and Paste Charts as Picture in Different Workbook

Peter,

copying and pasting the charts as pictures would be embedded in a larger
piece of code, which have the following dims already, which might conflict
with your dims:

Dim I As Integer
Dim ShName As String
Dim Sht As Worksheet
Dim buttoms As Shape

since I"m a novice at vba, don't really know how to modify your code without
pasting all my original code here (there's a lot).

here is a piece of code that might be simpler to embed in my existing code:

Workbooks("Hot List.xls").Sheets("Snapshot").Range("c48:i64").Cop yPicture _
Appearance:=xlScreen, Format:=xlPicture

But when I try to paste this into the new worksheet, it doesn't work:

With ThisWorkbook.Sheets(ShName).Range("c48").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
Link:=False _
, DisplayAsIcon:=False

Is there a quick fix for this, given the dim definitions above?

further on, there is this piece of code:

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next

this might be deleting the chart pictures as well? An MVP sent me a link to
a site showing how to delete buttons only, but haven't digged into to it yet.

I can send you the entire code offline if you're interested...

thanks very much for your time and help.

Steve

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Copy and Paste Charts as Picture in Different Workbook

Based on already what I have coded, this will probably work best for me:

Workbooks("Hot List.xls").Sheets("Snapshot").Range("c48:i64").Cop yPicture _
Appearance:=xlScreen, Format:=xlPicture

With ThisWorkbook.Sheets(ShName).Range("c48").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)", _
Link:=False, DisplayAsIcon:=False

End With

The trick is getting this picture into the the new worksheet and in the
right place (c48) of the new worksheet. Instead I'm finding the picture
being pasted in the top left corner of the source page (Hot List.xls /
Snapshot). Not the new workbook / worksheet as defined by
"ThisWorkbook.Sheets(ShName).

Dim I As Integer
Dim ShName As String
Dim Sht As Worksheet
Dim buttoms As Shape

and this piece of code doesn't help, deleting all shapes including pictures:

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next

A big headache. thanks for everyone for taking a look; don't really expect
a response to this, but had to try.

SteveC







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Copy and Paste Charts as Picture in Different Workbook

Test my earlier example with a few charts on a sheet, amend the sheet
references to suit. Notice the bit about changing newly pasted pictures
positions to same Left & Top properties of the copied chartobject.

Regards,
Peter T

"SteveC" wrote in message
...
Based on already what I have coded, this will probably work best for me:

Workbooks("Hot

List.xls").Sheets("Snapshot").Range("c48:i64").Cop yPicture _
Appearance:=xlScreen, Format:=xlPicture

With ThisWorkbook.Sheets(ShName).Range("c48").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)", _
Link:=False, DisplayAsIcon:=False

End With

The trick is getting this picture into the the new worksheet and in the
right place (c48) of the new worksheet. Instead I'm finding the picture
being pasted in the top left corner of the source page (Hot List.xls /
Snapshot). Not the new workbook / worksheet as defined by
"ThisWorkbook.Sheets(ShName).

Dim I As Integer
Dim ShName As String
Dim Sht As Worksheet
Dim buttoms As Shape

and this piece of code doesn't help, deleting all shapes including

pictures:

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next

A big headache. thanks for everyone for taking a look; don't really

expect
a response to this, but had to try.

SteveC







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Copy and Paste Charts as Picture in Different Workbook

Hi Steve,

copying and pasting the charts as pictures would be embedded in a larger
piece of code, which have the following dims already, which might conflict
with your dims:


Although you could amend and embed my eample into your existing code there's
anotrher way, referring to the example

Change -
Sub test()
to -
Sub CopyChartsToPictures(wsSource As Worksheet, wsDest As Worksheet)

Delete or comment the two Dim ref's to wsSource and wsDest

In your existing code add a line something like this -

CopyChartsToPictures ThisWorkbook.Sheets(ShName), ActiveSheet

If I follow, ThisWorkbook.Sheets(ShName) is the sheet containing charts to
be copied as pictures and ActiveSheet is the sheet where they are to be
pasted. If not, amend the sheet references to suit.

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next
this might be deleting the chart pictures as well? An MVP sent me a link

to
a site showing how to delete buttons only, but haven't digged into to it

yet.

Try simply -
ActiveSheet.Buttons.Delete

deletes all buttons inserted from the Forms menu (not ActiveX Commandbuttons
from the Controls Toolbox menu)

Notice I didn't qualify ActiveSheet to ThisWorkbook (this file containing
the code). The ActiveSheet can only be the the activesheet in the
activeworkbook, which may or may not be ThisWorkbook. Perhaps you need to be
more explicit aboput which sheet you need to refer to.

Regards,
Peter T


"SteveC" wrote in message
...
Peter,

copying and pasting the charts as pictures would be embedded in a larger
piece of code, which have the following dims already, which might conflict
with your dims:

Dim I As Integer
Dim ShName As String
Dim Sht As Worksheet
Dim buttoms As Shape

since I"m a novice at vba, don't really know how to modify your code

without
pasting all my original code here (there's a lot).

here is a piece of code that might be simpler to embed in my existing

code:

Workbooks("Hot

List.xls").Sheets("Snapshot").Range("c48:i64").Cop yPicture _
Appearance:=xlScreen, Format:=xlPicture

But when I try to paste this into the new worksheet, it doesn't work:

With ThisWorkbook.Sheets(ShName).Range("c48").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
Link:=False _
, DisplayAsIcon:=False

Is there a quick fix for this, given the dim definitions above?

further on, there is this piece of code:

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next

this might be deleting the chart pictures as well? An MVP sent me a link

to
a site showing how to delete buttons only, but haven't digged into to it

yet.

I can send you the entire code offline if you're interested...

thanks very much for your time and help.

Steve



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Copy and Paste Charts as Picture in Different Workbook

I think I'm close.

Issue 1)
ThisWorkbook.Sheets(ShName) is the destination sheet where I want to paste
the charts (and everything else).

Another workbook / worksheet, Hot List.xls / Snapshot, is the source sheet
containing charts (and everything else).

I'll try to figure this out.

Issue 2)
Don't no if related, but:

I get an error: compile error: variable not defined

the debugger highlights this the I in: For I = 1 To
wsSource.ChartObjects.Count within the following modified code:



Sub CopyChartsToPictures(wsSource As Worksheet, wsDest As Worksheet)
Dim nPicCnt As Long
Dim chtObj As ChartObject
'Dim wsSource As Worksheet
'Dim wsDest As Worksheet
Dim pic As picture
'Dim I As Long

Set wsSource = Workbooks("Book2").Worksheets("Sheet1")
Set wsDest = Workbooks("Book3").Worksheets("Sheet1")

nPicCnt = wsDest.Pictures.Count

For I = 1 To wsSource.ChartObjects.Count
Set chtObj = wsSource.ChartObjects(I)

chtObj.CopyPicture Appearance:=xlScreen, Format:=xlPicture

wsDest.Paste

nPicCnt = nPicCnt + 1
With wsDest.Pictures(nPicCnt)
.Left = chtObj.Left
.Top = chtObj.Top
End With
Next

End Sub

"Peter T" wrote:

Hi Steve,

copying and pasting the charts as pictures would be embedded in a larger
piece of code, which have the following dims already, which might conflict
with your dims:


Although you could amend and embed my eample into your existing code there's
anotrher way, referring to the example

Change -
Sub test()
to -
Sub CopyChartsToPictures(wsSource As Worksheet, wsDest As Worksheet)

Delete or comment the two Dim ref's to wsSource and wsDest

In your existing code add a line something like this -

CopyChartsToPictures ThisWorkbook.Sheets(ShName), ActiveSheet

If I follow, ThisWorkbook.Sheets(ShName) is the sheet containing charts to
be copied as pictures and ActiveSheet is the sheet where they are to be
pasted. If not, amend the sheet references to suit.

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next
this might be deleting the chart pictures as well? An MVP sent me a link

to
a site showing how to delete buttons only, but haven't digged into to it

yet.

Try simply -
ActiveSheet.Buttons.Delete

deletes all buttons inserted from the Forms menu (not ActiveX Commandbuttons
from the Controls Toolbox menu)

Notice I didn't qualify ActiveSheet to ThisWorkbook (this file containing
the code). The ActiveSheet can only be the the activesheet in the
activeworkbook, which may or may not be ThisWorkbook. Perhaps you need to be
more explicit aboput which sheet you need to refer to.

Regards,
Peter T


"SteveC" wrote in message
...
Peter,

copying and pasting the charts as pictures would be embedded in a larger
piece of code, which have the following dims already, which might conflict
with your dims:

Dim I As Integer
Dim ShName As String
Dim Sht As Worksheet
Dim buttoms As Shape

since I"m a novice at vba, don't really know how to modify your code

without
pasting all my original code here (there's a lot).

here is a piece of code that might be simpler to embed in my existing

code:

Workbooks("Hot

List.xls").Sheets("Snapshot").Range("c48:i64").Cop yPicture _
Appearance:=xlScreen, Format:=xlPicture

But when I try to paste this into the new worksheet, it doesn't work:

With ThisWorkbook.Sheets(ShName).Range("c48").Select
ActiveSheet.PasteSpecial Format:="Picture (Enhanced Metafile)",
Link:=False _
, DisplayAsIcon:=False

Is there a quick fix for this, given the dim definitions above?

further on, there is this piece of code:

For Each buttoms In ThisWorkbook.ActiveSheet.Shapes
buttoms.Delete
Next

this might be deleting the chart pictures as well? An MVP sent me a link

to
a site showing how to delete buttons only, but haven't digged into to it

yet.

I can send you the entire code offline if you're interested...

thanks very much for your time and help.

Steve




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
Copy range and paste as picture jlclyde Excel Discussion (Misc queries) 2 April 28th 08 09:52 PM
Copy and Paste Chart as Picture into another workbook or worksheet SteveC Charts and Charting in Excel 1 February 15th 07 11:47 PM
Copy and paste a graph as a picture? funkymonkUK[_104_] Excel Programming 2 March 17th 06 02:45 PM
Copy and paste a graph as a picture? funkymonkUK[_103_] Excel Programming 1 March 17th 06 02:35 PM
copy charts & paste as picture, hide chart, size & place same picture as chart Gunnar Johansson Excel Programming 0 October 30th 04 01:22 AM


All times are GMT +1. The time now is 02:43 AM.

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"