Sign in to follow this  
Followers 0
silvanr

obj excel charts

5 posts in this topic

I would like to write a Script that this diagram creates automatically.

This is a VBA Macro:

Sub char()

Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Sheets("Tabelle2").Range("B1:B5"), PlotBy _
        :=xlColumns
    ActiveChart.SeriesCollection(1).XValues = "=Tabelle2!R1C1:R5C1"
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Tabelle1"
    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = False
    End With
    ActiveChart.HasLegend = False
    ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
End Sub

I have already this in AutoIt:

;Create obj
    $MyObject = ObjCreate("Excel.Application"); Create an Excel Object  
    if @error then 
        Msgbox (0,"Excel Error:","Error creating Excel object!")
        exit(1)
    endif   
    if Not IsObj($MyObject) then 
        Msgbox (16,"Excel Error:","Excel obj wurde nicht richtig erstellt")
        exit
    endif
    
    $MyObject.Visible = 1
    $MyObject.workbooks.add

    $MyObject.Sheets("Tabelle2").Select
    $myObject.Charts.add
    WITH $MyObject.ActiveChart
        .ChartType = 51;xlColumnClustered
        
    ENDWITH


$MyObject = 0

How can I translate this:

ActiveChart.SetSourceData Source:=Sheets("Tabelle2").Range("B1:B5"), PlotBy :=xlColumns

I don't know, what I with ",:" can make.

Can someone help me? thx


Sorry, which my English is so bad. I come from Switzerland ;-)

Share this post


Link to post
Share on other sites



is it not possible?


Sorry, which my English is so bad. I come from Switzerland ;-)

Share this post


Link to post
Share on other sites

All of the things that starrt with xl are Enum constansts and are not automatically available to AutoIt.

Check out this post for a method of extracting Enums and using them in AutoIt.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I know that all of the things that starrt with xl are Enum constansts.

thx

I successfully made it :-)

...
    $MyObject.Sheets("Tabelle1").Select
    $myObject.Charts.add
    WITH $MyObject.ActiveChart
        .ChartType = 51;xlColumnClustered
        .SetSourceData($MyObject.Sheets("Tabelle2").Range("B1:B5"))
        .SeriesCollection(1).XValues = "=Tabelle2!Z1S1:Z5S1"
        .ApplyDataLabels(2, False);Wert oben anzeigen
        .HasLegend = False
        .Location (2, "Tabelle1"); Wo soll die Charts eingefügt werden

    ENDWITH
    $myObject.ActiveSheet.Shapes("Diagramm 1").Left = 0
    $myObject.ActiveSheet.Shapes("Diagramm 1").Top = 0
...

Sorry, which my English is so bad. I come from Switzerland ;-)

Share this post


Link to post
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
Sign in to follow this  
Followers 0