Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Keep Chart-Delete data?

Hi Sharad,
This method works, but I am trying to stay out of another application. This
is the code I have so far:
Sub Macro3()
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = False
Selection.Delete
ActiveSheet.Paste
End Sub

The error I get is:
"Run time error '1004':" & "Paste Method of Worksheet Class Failed"

But at this point I can manually paste from the clipboard and get a
"picture", which allows me to go back to the original data and delete it. I
am not sure how to access the system clipboard, which must be differant than
the Worksheet clipboard, although I find this a little puzzeling.
ActiveWindow.Visible = False seems to indicate I am no longer in Excel, but
the immediate window says I am on the Sheet. Both Activeshhet.Name and
Activecell.Name get results. Any Ideas?


"Sharad" wrote:

For this you can copy the chart as an image (Picture) and paste back as
an image.

Right click the chart and select copy.
Start a winword document (or may be paint brush). Right click there at
paste. The chart gets pasted as a picture.

In execel delete the data , and the chart.
In winword, right click on the chart image and select copy.
In excel paste it where you want.

Sharad



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Keep Chart-Delete data?

Oh OK, you didn't say you wanted to do it in VBE
Anyway, try following code.

Sub chartPix()
Dim chartShp As Shape, chartName As String, shtName As String
Dim exLeft As Single, exTop As Single
shtName = ActiveSheet.Name
chartName = ActiveChart.Name
chartName = Right(chartName, Len(chartName) - Len(shtName))
chartName = Trim(chartName)
Set chartShp = ActiveSheet.Shapes(chartName)
exLeft = chartShp.Left
exTop = chartShp.Top
chartShp.CopyPicture xlScreen
chartShp.Delete
ActiveSheet.Paste
Selection.Left = exLeft
Selection.Top = exTop

End Sub

If there is no any chart in active sheet or selection is not a chart
then it will give error. I did not add error handling part.

Sharad




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Keep Chart-Delete data?

Hi Sharad,
Most excellant. Thank you for your help. "chartShp.CopyPicture xlScreen" was
completely new to me. In fact when I tried to look it up, I can not find it.
Again, thank you.

"Sharad" wrote:

Oh OK, you didn't say you wanted to do it in VBE
Anyway, try following code.

Sub chartPix()
Dim chartShp As Shape, chartName As String, shtName As String
Dim exLeft As Single, exTop As Single
shtName = ActiveSheet.Name
chartName = ActiveChart.Name
chartName = Right(chartName, Len(chartName) - Len(shtName))
chartName = Trim(chartName)
Set chartShp = ActiveSheet.Shapes(chartName)
exLeft = chartShp.Left
exTop = chartShp.Top
chartShp.CopyPicture xlScreen
chartShp.Delete
ActiveSheet.Paste
Selection.Left = exLeft
Selection.Top = exTop

End Sub

If there is no any chart in active sheet or selection is not a chart
then it will give error. I did not add error handling part.

Sharad




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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
How to delete chart NonTechie Charts and Charting in Excel 7 September 24th 09 05:59 AM
delete chart Wayne Excel Discussion (Misc queries) 6 May 3rd 07 03:00 PM
how to ensure that the chart will be deleted after i delete data Sagar Bhandari Charts and Charting in Excel 1 October 21st 05 01:59 PM
Delete Chart agac8103 Charts and Charting in Excel 3 December 13th 04 04:54 AM


All times are GMT +1. The time now is 05:59 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"