Jump to content

Creating Excel Charts


Recommended Posts

Hello,

I sent a few PMs to people who have graciously helped me in the past, and then decided it would be better to post my question here in order to share the answers with the entire forum.

I did search on excel charts and only ran across a few links that were pretty old. So if anyone has any updated information to share, I would greatly appreciate it.

As the title states, I am trying to create an excel chart using AutoIt.

Thank you.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

Hi,

I was playing around with excel charts and here is what I

came up with.

Hope you can get some ideas from it.

Good Luck.

$EA=ObjCreate("Excel.Application")

$EA.Workbooks.Add

$EA.Worksheets(3).Delete

$EA.Worksheets(2).Delete

For $I=1 To 20

For $J=1 To 20

$EA.Cells($I,$J).Value=Random(1,20,1)

Next

Next

$EA.Range("A1:T20").Select

$EA.Charts.Add()

$EA.ActiveChart.HasTitle=TRUE

$EA.ActiveChart.ChartTitle.Characters.Text="20 by 20 Random Numbers 1 to 20"

$EA.ActiveChart.ChartType=62

$EA.Visible = True

msgbox(4096,"Excel Chart","Click OK When Done...")

$EA.Quit

$Tit="Microsoft Excel"

Opt("WinTitleMatchMode",3)

WinWait($Tit)

ControlClick($Tit,"","[iD:7]")

Link to comment
Share on other sites

Charts are a little involved and I haven't gotten around to wrapping them into a UDF. I'll get to it at some point.

In the meantime, you can use Randallc's _ExcelCOM, which facilitates charting.

As well, if you record a macro of you making a chart, and paste the resulting VBA code here, I can pretty quickly convert it into AutoIt code. If nothing else, you can use it as starting point for programming your own charts.

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
Link to comment
Share on other sites

  • 9 months later...

Charts are a little involved and I haven't gotten around to wrapping them into a UDF. I'll get to it at some point.

In the meantime, you can use Randallc's _ExcelCOM, which facilitates charting.

As well, if you record a macro of you making a chart, and paste the resulting VBA code here, I can pretty quickly convert it into AutoIt code. If nothing else, you can use it as starting point for programming your own charts.

-S

Hi Locodarwin,

I'm currently working on exactly that, I'm trying to figure out the whole charts in excel, and I'll paste the code in here, if you can be so kind to convert it, it would be great.

Sub Macro2()

'

' Macro2 Macro

' Macro recorded 03/02/2009 by Michael Roll

'

'

Charts.Add

ActiveChart.ChartType = xlLineMarkers

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B2:P17"), PlotBy _

:=xlRows

ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"

With ActiveChart

.HasTitle = False

.Axes(xlCategory, xlPrimary).HasTitle = False

.Axes(xlValue, xlPrimary).HasTitle = False

End With

ActiveSheet.Shapes("Chart 2").IncrementLeft -261.75

ActiveSheet.Shapes("Chart 2").IncrementTop 62.25

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B2:B17,D2:P17"), _

PlotBy:=xlRows

End Sub

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...