![]() |
how to superimpose chart images or extract data by vba
how to superimpose 2 charts or extract data by vba
|
how to superimpose chart images or extract data by vba
Here's part 2:
Macro to extract data from a chart in Excel http://support.microsoft.com/kb/300643 Part 1 may be satisfied by creating a combination chart. What types of chart are you trying to superimpose? Actually superimposing one chart on another, requires you to equalize the left and top positions and the width and height dimensions of the two chart objects. You may also need to equalize these parameters for the plot areas as well. ''''''''''''''''''''''''''''''' snippet Dim cht1 As ChartObject Dim cht2 As ChartObject Set cht1 = ActiveSheet.ChartObjects(1) Set cht2 = ActiveSheet.ChartObjects(2) ' equalize chart size and position cht2.Left = cht1.Left cht2.Top = cht1.Top cht2.Width = cht1.Width cht2.Height= cht1.Height ' temporarily shrink plot area cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2 cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2 ' equalize plot area size and position cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height ''''''''''''''''''''''''''''''' end snippet Long ago I posted a small utility to do this on my web site: Align Excel Charts Using VBA http://peltiertech.com/Excel/Charts/AlignCharts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: how to superimpose 2 charts or extract data by vba |
how to superimpose chart images or extract data by vba
If you are dealing with static images, then my suggestions will be of no
use. You can superimpose the two images, but if they are not the same size, nor scaled the same, and if they don't have transparent backgrounds, you will not gain anything from this exercise. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Jon Peltier wrote: Here's part 2: Macro to extract data from a chart in Excel http://support.microsoft.com/kb/300643 Part 1 may be satisfied by creating a combination chart. What types of chart are you trying to superimpose? Actually superimposing one chart on another, requires you to equalize the left and top positions and the width and height dimensions of the two chart objects. You may also need to equalize these parameters for the plot areas as well. ''''''''''''''''''''''''''''''' snippet Dim cht1 As ChartObject Dim cht2 As ChartObject Set cht1 = ActiveSheet.ChartObjects(1) Set cht2 = ActiveSheet.ChartObjects(2) ' equalize chart size and position cht2.Left = cht1.Left cht2.Top = cht1.Top cht2.Width = cht1.Width cht2.Height= cht1.Height ' temporarily shrink plot area cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2 cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2 ' equalize plot area size and position cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height ''''''''''''''''''''''''''''''' end snippet Long ago I posted a small utility to do this on my web site: Align Excel Charts Using VBA http://peltiertech.com/Excel/Charts/AlignCharts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: how to superimpose 2 charts or extract data by vba |
how to superimpose chart images or extract data by vba
thanks to Jon,
Actually my problem is to call out the yield curve (line graph) from the same web but for different date. Thus both images have the same axis. The easiest way for immedaite comparison is to superimpose both, get the top peice of transparent abckground (here is the problem I cannot manage). If I can extract data from the graph by VBA, so much the better. I can then do deeper analysis. as for your macro. I shall try on that this week-end. "Jon Peltier" wrote: If you are dealing with static images, then my suggestions will be of no use. You can superimpose the two images, but if they are not the same size, nor scaled the same, and if they don't have transparent backgrounds, you will not gain anything from this exercise. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Jon Peltier wrote: Here's part 2: Macro to extract data from a chart in Excel http://support.microsoft.com/kb/300643 Part 1 may be satisfied by creating a combination chart. What types of chart are you trying to superimpose? Actually superimposing one chart on another, requires you to equalize the left and top positions and the width and height dimensions of the two chart objects. You may also need to equalize these parameters for the plot areas as well. ''''''''''''''''''''''''''''''' snippet Dim cht1 As ChartObject Dim cht2 As ChartObject Set cht1 = ActiveSheet.ChartObjects(1) Set cht2 = ActiveSheet.ChartObjects(2) ' equalize chart size and position cht2.Left = cht1.Left cht2.Top = cht1.Top cht2.Width = cht1.Width cht2.Height= cht1.Height ' temporarily shrink plot area cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2 cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2 ' equalize plot area size and position cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height ''''''''''''''''''''''''''''''' end snippet Long ago I posted a small utility to do this on my web site: Align Excel Charts Using VBA http://peltiertech.com/Excel/Charts/AlignCharts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: how to superimpose 2 charts or extract data by vba |
how to superimpose chart images or extract data by vba
Remember: the macros I posted will work on charts.
You might be able to save the image as a GIF or PNG, open it in an image editor (I like IrfanVIEW), and save it with white as the transparent color. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: thanks to Jon, Actually my problem is to call out the yield curve (line graph) from the same web but for different date. Thus both images have the same axis. The easiest way for immedaite comparison is to superimpose both, get the top peice of transparent abckground (here is the problem I cannot manage). If I can extract data from the graph by VBA, so much the better. I can then do deeper analysis. as for your macro. I shall try on that this week-end. "Jon Peltier" wrote: If you are dealing with static images, then my suggestions will be of no use. You can superimpose the two images, but if they are not the same size, nor scaled the same, and if they don't have transparent backgrounds, you will not gain anything from this exercise. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Jon Peltier wrote: Here's part 2: Macro to extract data from a chart in Excel http://support.microsoft.com/kb/300643 Part 1 may be satisfied by creating a combination chart. What types of chart are you trying to superimpose? Actually superimposing one chart on another, requires you to equalize the left and top positions and the width and height dimensions of the two chart objects. You may also need to equalize these parameters for the plot areas as well. ''''''''''''''''''''''''''''''' snippet Dim cht1 As ChartObject Dim cht2 As ChartObject Set cht1 = ActiveSheet.ChartObjects(1) Set cht2 = ActiveSheet.ChartObjects(2) ' equalize chart size and position cht2.Left = cht1.Left cht2.Top = cht1.Top cht2.Width = cht1.Width cht2.Height= cht1.Height ' temporarily shrink plot area cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2 cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2 ' equalize plot area size and position cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height ''''''''''''''''''''''''''''''' end snippet Long ago I posted a small utility to do this on my web site: Align Excel Charts Using VBA http://peltiertech.com/Excel/Charts/AlignCharts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: how to superimpose 2 charts or extract data by vba |
how to superimpose chart images or extract data by vba
thanks to Jon
I shall try on that. "Jon Peltier" wrote: Remember: the macros I posted will work on charts. You might be able to save the image as a GIF or PNG, open it in an image editor (I like IrfanVIEW), and save it with white as the transparent color. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: thanks to Jon, Actually my problem is to call out the yield curve (line graph) from the same web but for different date. Thus both images have the same axis. The easiest way for immedaite comparison is to superimpose both, get the top peice of transparent abckground (here is the problem I cannot manage). If I can extract data from the graph by VBA, so much the better. I can then do deeper analysis. as for your macro. I shall try on that this week-end. "Jon Peltier" wrote: If you are dealing with static images, then my suggestions will be of no use. You can superimpose the two images, but if they are not the same size, nor scaled the same, and if they don't have transparent backgrounds, you will not gain anything from this exercise. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Jon Peltier wrote: Here's part 2: Macro to extract data from a chart in Excel http://support.microsoft.com/kb/300643 Part 1 may be satisfied by creating a combination chart. What types of chart are you trying to superimpose? Actually superimposing one chart on another, requires you to equalize the left and top positions and the width and height dimensions of the two chart objects. You may also need to equalize these parameters for the plot areas as well. ''''''''''''''''''''''''''''''' snippet Dim cht1 As ChartObject Dim cht2 As ChartObject Set cht1 = ActiveSheet.ChartObjects(1) Set cht2 = ActiveSheet.ChartObjects(2) ' equalize chart size and position cht2.Left = cht1.Left cht2.Top = cht1.Top cht2.Width = cht1.Width cht2.Height= cht1.Height ' temporarily shrink plot area cht2.Chart.PlotArea.Width = cht2.Chart.PlotArea.Width / 2 cht2.Chart.PlotArea.Height= cht2.Chart.PlotArea.Height / 2 ' equalize plot area size and position cht2.Chart.PlotArea.Left = cht1.Chart.PlotArea.Left cht2.Chart.PlotArea.Top = cht1.Chart.PlotArea.Top cht2.Chart.PlotArea.Width = cht1.Chart.PlotArea.Width cht2.Chart.PlotArea.Height= cht1.Chart.PlotArea.Height ''''''''''''''''''''''''''''''' end snippet Long ago I posted a small utility to do this on my web site: Align Excel Charts Using VBA http://peltiertech.com/Excel/Charts/AlignCharts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Davyboom wrote: how to superimpose 2 charts or extract data by vba |
All times are GMT +1. The time now is 02:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com