Jump to content

copy charts in excel and paste them into powerpoint


ToyBoi
 Share

Recommended Posts

Hello everyone, I have a folder with over 100 csv files.

1.Preferably I would like to save them as xls with Autoit if that is doable. (done, i have made a csv to xls converter in vba that will loop through all the files in a given folder)

2.The main problem is that i have written a macro that will loop through all the excel files in the folder and create 2 charts for each file. Is there a way to get Autoit to copy each of these 2 charts in every excel file and paste them (as picture) in a powerpoint presentation or word document?

thanks a bunch

Edited by ToyBoi
Link to comment
Share on other sites

@ToyBoi

I would say there is probably a way. However, what you've found is that no one is willing to just pick up your project and code it for you. You need to code some, and come with a specific problem. Otherwise, I am rather surprised no one answered this thread with a simple "Yes".

Enjoy,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Hello JS, I'm actually already finished with the vba macro which does all the charting, I'm sorry if I wasn't clear about that. I can provide the files if needed, but I don't think that people wants/needs to see them anyways.

And really I'm not asking people to code it for me, maybe just a pointer of which topic of help file i should look up.

I know I don't want to do print screen because the 1 of the charts is on top of the other. so to redefine question then,

is there a command that will be able to recognize a chart in excel and select it? and is there a command that will be able to paste a chart as image (not excel chart)

Link to comment
Share on other sites

Hello JS, I'm actually already finished with the vba macro which does all the charting, I'm sorry if I wasn't clear about that. I can provide the files if needed, but I don't think that people wants/needs to see them anyways.

And really I'm not asking people to code it for me, maybe just a pointer of which topic of help file i should look up.

I know I don't want to do print screen because the 1 of the charts is on top of the other. so to redefine question then,

is there a command that will be able to recognize a chart in excel and select it? and is there a command that will be able to paste a chart as image (not excel chart)

For the pasting of the chart once you have it "copied" to the clipboard you can look at the _ClipBoard functions in the latest release. They can also copy the image if we can figure out how to get it selected. I am going to look into the Excel.au3 functions and see what I can come up with for selecting a chart (after recognizing it). Can you not select the chart in VBA from Excel, and then maybe use AutoIt to past it into another sheet? (Just also trying to think of alternative methods for fixing your issues)

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I believe this link should also help in your endeavors. It should show you how to interact with the chart object in VBA, which isn't much different from doing the same in AutoIt.

http://msdn.microsoft.com/en-us/library/bb210112.aspx

Edit01: Added link as pointed out by DaRam that I didn't :)...DaRam That is a bit of what the site was saying.

Thanks,

Jarvis

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

JS you forgot to insert the hyperlink. :)

This might be a VBA fragment that could help the OP:

' Select the First Chart from the Workbook Object
              objChartWB.Activate
              objChartWBActiveSheet.ChartObjects(objChartWB.ActiveSheet.ChartObjects(1).Name).Activate
              ' Export it to an Image File
              objChartWB.ActiveChart.Export "C:\SomeChart.GIF", "GIF"

I believe this link should also help in your endeavors. It should show you how to interact with the chart object in VBA, which isn't much different from doing the same in AutoIt.

Thanks,

Jarvis

Link to comment
Share on other sites

thanks everyone.

here is a sample of one of the excel file with the 2 charts if anyone is interested

http://www.mediafire.com/?sharekey=850a7e3...04e75f6e8ebb871

i tried to record a marco and it seems the charts are always called chart1 and chart2. So yes it would be possible to select the chart with vba

i can just do something like

chart(1).select

selection.copy

but after that i would need Autoit to interact with powerpoint because i'm not sure if vba is capable of doing that.

and since there is no function for autoit to insert a macro into excel, i will probably actually have to use send keys to record macro first, enter the code and then run it. This is something i already do on a different autoit prgram in order to run a lengthy macro. However it would probably slow the process down by a lot in this situation.

exporting them to GIFs sounds like a wonderful idea, I'm going to give that a try and see how that works out

Edited by ToyBoi
Link to comment
Share on other sites

so i used this code in vba which will export all the charts in my excel to gifs

Sub ExportMyCharts()
Dim MyPath as String
Dim i as Long
MyPath = ActiveWorkbook.Path
For i = 1 to ActiveSheet.ChartObjects.Count
ActiveSheet.Chartobjects(i).Chart.Export _
MyPath & "\Chart" & Format(i, "000") & ".gif", "GIF"
Next
End Sub

I can do a loop which will perform this code on al the excel files. In the end I will end up with over 100 gifs.

So the next step it too paste these gifs into powerpoint :) Any ideas?

Link to comment
Share on other sites

so i used this code in vba which will export all the charts in my excel to gifs

Sub ExportMyCharts()
Dim MyPath as String
Dim i as Long
MyPath = ActiveWorkbook.Path
For i = 1 to ActiveSheet.ChartObjects.Count
ActiveSheet.Chartobjects(i).Chart.Export _
MyPath & "\Chart" & Format(i, "000") & ".gif", "GIF"
Next
End Sub

I can do a loop which will perform this code on al the excel files. In the end I will end up with over 100 gifs.

So the next step it too paste these gifs into powerpoint :) Any ideas?

Did you look at the _ClipBoard* functions in the helpfile? I think this should easily be done with those...

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...