PC Review


Reply
Thread Tools Rate Thread

copy charts & paste as picture, hide chart, size & place same picture as chart

 
 
Gunnar Johansson
Guest
Posts: n/a
 
      30th Oct 2004
Hi,

I have 15 charts in one worksheet and want to go through them and have them
all unvisible put instead show a picture of them.

I have now tried to much of my own and would be grateful to any help, parts
or in whole. I have this code right now, but get error on line W "=
chtobj.Width" . I feel that it will not be the last debug error in it, so
please help me...


Private Sub CopyChart()
Application.EnableEvents = False
Application.ScreenUpdating = True

Dim chtobj As ChartObject
Dim W As Double
Dim H As Double
Dim T As Double
Dim L As Double
Dim Pic As Image

For Each chtobj In Sheet1.ChartObjects
W = chtobj.Width
H = chtobj.Height
L = chtobj.Left
T = chtobj.Top
chtobj.Visible = False
chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Pictures.Paste.Select
With Selection
.Width = W
.Height = H
.Left = L
.Top = T
End With
Next chtobj

Application.EnableEvents = False
Application.ScreenUpdating = True
Exit Sub

/Regards


 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      30th Oct 2004
works for me...

Tim

Sub CopyChart()

Dim chtobj As ChartObject

ActiveSheet.Range("A1").Select
For Each chtobj In Sheet1.ChartObjects
chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Paste

With Selection
.Left = chtobj.Left
.Top = chtobj.Top
.Width = chtobj.Width
.Height = chtobj.Height
End With
chtobj.Visible = False
Next chtobj
End Sub


"Gunnar Johansson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have 15 charts in one worksheet and want to go through them and
> have them all unvisible put instead show a picture of them.
>
> I have now tried to much of my own and would be grateful to any
> help, parts or in whole. I have this code right now, but get error
> on line W "= chtobj.Width" . I feel that it will not be the last
> debug error in it, so please help me...
>
>
> Private Sub CopyChart()
> Application.EnableEvents = False
> Application.ScreenUpdating = True
>
> Dim chtobj As ChartObject
> Dim W As Double
> Dim H As Double
> Dim T As Double
> Dim L As Double
> Dim Pic As Image
>
> For Each chtobj In Sheet1.ChartObjects
> W = chtobj.Width
> H = chtobj.Height
> L = chtobj.Left
> T = chtobj.Top
> chtobj.Visible = False
> chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> ActiveSheet.Pictures.Paste.Select
> With Selection
> .Width = W
> .Height = H
> .Left = L
> .Top = T
> End With
> Next chtobj
>
> Application.EnableEvents = False
> Application.ScreenUpdating = True
> Exit Sub
>
> /Regards
>



 
Reply With Quote
 
Gunnar Johansson
Guest
Posts: n/a
 
      30th Oct 2004
Thank you, it work for me to.

Could anybody please tell me how to delete the pictures? I can't find a
syntax to work to separate chartobjects from pictures.

A For each...Next modell would be handy. Anybody? Tim ?

Thanks again, Im on the track now.

/Regards



"Tim Williams" <saxifrax@pacbell*dot*net> skrev i meddelandet
news:(E-Mail Removed)...
> works for me...
>
> Tim
>
> Sub CopyChart()
>
> Dim chtobj As ChartObject
>
> ActiveSheet.Range("A1").Select
> For Each chtobj In Sheet1.ChartObjects
> chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
> ActiveSheet.Paste
>
> With Selection
> .Left = chtobj.Left
> .Top = chtobj.Top
> .Width = chtobj.Width
> .Height = chtobj.Height
> End With
> chtobj.Visible = False
> Next chtobj
> End Sub
>
>
> "Gunnar Johansson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>> I have 15 charts in one worksheet and want to go through them and have
>> them all unvisible put instead show a picture of them.
>>
>> I have now tried to much of my own and would be grateful to any help,
>> parts or in whole. I have this code right now, but get error on line W "=
>> chtobj.Width" . I feel that it will not be the last debug error in it, so
>> please help me...
>>
>>
>> Private Sub CopyChart()
>> Application.EnableEvents = False
>> Application.ScreenUpdating = True
>>
>> Dim chtobj As ChartObject
>> Dim W As Double
>> Dim H As Double
>> Dim T As Double
>> Dim L As Double
>> Dim Pic As Image
>>
>> For Each chtobj In Sheet1.ChartObjects
>> W = chtobj.Width
>> H = chtobj.Height
>> L = chtobj.Left
>> T = chtobj.Top
>> chtobj.Visible = False
>> chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
>> ActiveSheet.Pictures.Paste.Select
>> With Selection
>> .Width = W
>> .Height = H
>> .Left = L
>> .Top = T
>> End With
>> Next chtobj
>>
>> Application.EnableEvents = False
>> Application.ScreenUpdating = True
>> Exit Sub
>>
>> /Regards
>>

>
>



 
Reply With Quote
 
Gunnar Johansson
Guest
Posts: n/a
 
      30th Oct 2004
It was easy:
ActiveSheet.Pictures.Delete
Sorry to bother about that...

/Regards

"Gunnar Johansson" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed)...
> Thank you, it work for me to.
>
> Could anybody please tell me how to delete the pictures? I can't find a
> syntax to work to separate chartobjects from pictures.
>
> A For each...Next modell would be handy. Anybody? Tim ?
>
> Thanks again, Im on the track now.
>
> /Regards
>
>
>
> "Tim Williams" <saxifrax@pacbell*dot*net> skrev i meddelandet
> news:(E-Mail Removed)...
>> works for me...
>>
>> Tim
>>
>> Sub CopyChart()
>>
>> Dim chtobj As ChartObject
>>
>> ActiveSheet.Range("A1").Select
>> For Each chtobj In Sheet1.ChartObjects
>> chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
>> ActiveSheet.Paste
>>
>> With Selection
>> .Left = chtobj.Left
>> .Top = chtobj.Top
>> .Width = chtobj.Width
>> .Height = chtobj.Height
>> End With
>> chtobj.Visible = False
>> Next chtobj
>> End Sub
>>
>>
>> "Gunnar Johansson" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hi,
>>>
>>> I have 15 charts in one worksheet and want to go through them and have
>>> them all unvisible put instead show a picture of them.
>>>
>>> I have now tried to much of my own and would be grateful to any help,
>>> parts or in whole. I have this code right now, but get error on line W
>>> "= chtobj.Width" . I feel that it will not be the last debug error in
>>> it, so please help me...
>>>
>>>
>>> Private Sub CopyChart()
>>> Application.EnableEvents = False
>>> Application.ScreenUpdating = True
>>>
>>> Dim chtobj As ChartObject
>>> Dim W As Double
>>> Dim H As Double
>>> Dim T As Double
>>> Dim L As Double
>>> Dim Pic As Image
>>>
>>> For Each chtobj In Sheet1.ChartObjects
>>> W = chtobj.Width
>>> H = chtobj.Height
>>> L = chtobj.Left
>>> T = chtobj.Top
>>> chtobj.Visible = False
>>> chtobj.CopyPicture Appearance:=xlScreen, Format:=xlPicture
>>> ActiveSheet.Pictures.Paste.Select
>>> With Selection
>>> .Width = W
>>> .Height = H
>>> .Left = L
>>> .Top = T
>>> End With
>>> Next chtobj
>>>
>>> Application.EnableEvents = False
>>> Application.ScreenUpdating = True
>>> Exit Sub
>>>
>>> /Regards
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy chart and paste it as a PICTURE back into Excel AC Microsoft Excel Discussion 3 6th Jun 2009 07:51 AM
Copy chart and paste it as a PICTURE back into Excel AC Microsoft Excel Programming 3 6th Jun 2009 07:51 AM
Chart Picture Size in UserForm/Picture Control. Dan Microsoft Excel Programming 8 30th May 2008 08:04 PM
Copy and Paste Chart as Picture into another workbook or worksheet =?Utf-8?B?U3RldmVD?= Microsoft Excel Charting 1 15th Feb 2007 11:47 PM
copy then paste a chart as a picture =?Utf-8?B?Qmlu?= Microsoft Excel Programming 1 17th Jun 2005 05:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:20 AM.