water

ExcelChart UDF - Help & Support

113 posts in this topic

This is the "General Help and Support" thread for the ExcelChart UDF.

The UDF itself can be downloaded

So if you have any questions, suggestions or errors please post here.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites



Hi Guys,

is there the possibilty to manage "error bars" with this great UDF?

For me error bars are the better solution to achive this:

Posted Image

A scatter chart with a vertical error bar and a label: a "dynamic" vertical bar.

Suggestions?

Thanks!

Share this post


Link to post
Share on other sites

Hi maba,

not yet.

Can you create the vertical lines with Excel manually? If yes, you could create a macro and we can have alook at the VBA code and can try to translate it to AutoIt.

What version of Excel do you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

:)

Something like this:

Sub ErrorBar()
'
' ErrorBar Macro
'
'
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(2).Select
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(11).Name = "=""Error"""
    ActiveChart.SeriesCollection(11).XValues = "='Tabelle gestione grafico'!$H$9"
    ActiveChart.SeriesCollection(11).Values = "='Tabelle gestione grafico'!$I$9"
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).Select
    ActiveChart.SeriesCollection(8).HasErrorBars = True
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).ErrorBars.Select
    ActiveChart.SeriesCollection(11).ErrorBar Direction:=xlY, Include:= _
        xlMinusValues, Type:=xlFixedValue, Amount:=1
    ActiveChart.SeriesCollection(11).ErrorBars.EndStyle = xlNoCap
    ActiveChart.SeriesCollection(11).ErrorBar Direction:=xlY, Include:= _
        xlMinusValues, Type:=xlPercent, Amount:=5
    ActiveChart.SeriesCollection(11).ErrorBar Direction:=xlY, Include:= _
        xlMinusValues, Type:=xlPercent, Amount:=100
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).ErrorBars.Select
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).Select
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).ApplyDataLabels
    ActiveSheet.ChartObjects("Grafico 4").Activate
    ActiveChart.SeriesCollection(11).DataLabels.Select
    Selection.Position = xlLabelPositionCenter
End Sub

I think that I can use this for now, should it work.. right?

At least Office 2007!

Share this post


Link to post
Share on other sites

If you translate it to AutoIt it should work.

ActiveChart.SeriesCollection(11).ErrorBar Direction:=xlY, Include:=xlMinusValues, Type:=xlPercent, Amount:=100
should become something like:
ActiveChart.SeriesCollection(11).ErrorBar($xlY, $xlMinusValues, $xlPercent, 100)
(but I'm not 100% sure - I will have to test it tomorrow)

Can you post a screenshot of the resulting Excel chart? So we can test that we get the same result when we put the error bars into a function of the UDF.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

This

Sub Macro6()

    Range("A5:B5").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range("'Foglio1'!$A$5:$B$5")
    ActiveChart.ChartType = xlXYScatter
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).HasErrorBars = True
    ActiveChart.SeriesCollection(1).ErrorBars.Select
    ActiveChart.SeriesCollection(1).ErrorBars.EndStyle = xlNoCap
    ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:= _
        xlMinusValues, Type:=xlFixedValue, Amount:=1
    ActiveChart.ChartArea.Select
    ActiveChart.SeriesCollection(1).ApplyDataLabels

End Sub

generates

Posted Image

but macro does not:

  • apply the styles
  • center the label
  • delete the horizontal error bar
Posted Image

Thanks

Share this post


Link to post
Share on other sites

Not perfect, but I hope it's a good start:

#include <ExcelChart.au3>

; *****************************************************************************
; Create example environment
; *****************************************************************************
Global $aExcel = _XLChart_Example(True, 0, -1, -1, -1)
If @error = 2 Then Exit MsgBox(16, "Excel Chart Example Script", "The installed Excel version is not supported by this UDF!" & @CRLF & "Version must be >= 12 (Excel 2007).")
If @error <> 0 Then Exit MsgBox(16, "Excel Chart Example Script", "Error " & @error & " returned by _XLChart_Example on line " & @ScriptLineNumber)

$iXLC_Debug = 2
Global $iTop
_ExcelWriteCell($aExcel[0], "", "B2:B5")                                            ; Clear all cells but one
_XLChart_SeriesSet($aExcel[1] .SeriesCollection(1), $xlLine)                        ; Remove markers
$aExcel[1].SeriesCollection(1).HasErrorBars = True                                    ; Activate Error bars
$aExcel[1].SeriesCollection(1).ErrorBars.EndStyle = $xlNoCap                        ; No cap
$aExcel[1].SeriesCollection(1).ErrorBar($xlY, $xlMinusValues, $xlPercent, 100)        ; Set error bars
$aExcel[1].SeriesCollection(1).ApplyDataLabels()                                    ; Appl
$aExcel[1].SeriesCollection(1).DataLabels.Position = 0                                ; Set the data labels above
_XLChart_LineSet($aExcel[1].SeriesCollection(1).ErrorBars, 1, 0x4A7EBB)                ; Set line color for the error bar
_XLChart_LineSet($aExcel[1].SeriesCollection(1).DataLabels, 2, 0x4A7EBB)            ; Set line color of the data label
$iTop = $aExcel[1].SeriesCollection(1).Points(5).DataLabel.Top
$aExcel[1].SeriesCollection(1).Points(5).DataLabel.Top = $iTop + 5                    ; Reposition the data label
$aExcel[1].SeriesCollection(1).Points(5).DataLabel.Text = "Test"                    ; Set text of a point of the data label

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Ok, as is I have:

>Running AU3Check (1.54.22.0)  from:C:Program Files (x86)AutoIt3
Z:AutoITsamplesErrorBar.au3(15,93) : WARNING: $xlNoCap: possibly used before declaration.
$aExcel[1].SeriesCollection(1).ErrorBars.EndStyle = $xlNoCap                        ; No cap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Z:AutoITsamplesErrorBar.au3(16,45) : WARNING: $xlY: possibly used before declaration.
$aExcel[1].SeriesCollection(1).ErrorBar($xlY,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

If I declare the vars, script works but I've two "Type mismatch" debug info.. If not styles aren't applied.

Probably not important now.

Bars does not cross X axis, in fact Display -> Direction is set to Both and not Negative and Error Amount is set to Fixed value: 5.0 and not Percentage: 100. Why? ;)

Label is not set correctly.. next step :)

Edited by maba

Share this post


Link to post
Share on other sites

Sorry, forgot to replace this two constants with their values.

$xlNoCap = 2 and $xlY = 1

I will post a screenshot of what I got with Excel 2010 tomorrow.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Ok, is the right way :)

Posted Image

A little problem with the label.. but it is good. On Excel 2007.

Edited by maba

Share this post


Link to post
Share on other sites

#11 ·  Posted

The positioning of the text is not perfect in Excel 2010 too. We could either play around with changing the "left" property or to change the datalabels.position to center. But in this case the line will end in the center of the box. If we use a filling for the box then the line will be invisible and the text will be centered automatically.

I will check how much of the errorbar properties can be set by a function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#12 ·  Posted

Yes, box filling is perfect for me.

Thanks for your time!

Share this post


Link to post
Share on other sites

#13 ·  Posted

I'm going to post such an example tomorrow.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#14 ·  Posted

Hi maba,

here is the enhanced version:

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include-once
#include <ExcelChart.au3>

; *****************************************************************************
; Create example environment
; *****************************************************************************
Global $aExcel = _XLChart_Example(True, 0, -1, -1, -1)
If @error = 2 Then Exit MsgBox(16, "Excel Chart Example Script", "The installed Excel version is not supported by this UDF!" & @CRLF & "Version must be >= 12 (Excel 2007).")
If @error <> 0 Then Exit MsgBox(16, "Excel Chart Example Script", "Error " & @error & " returned by _XLChart_Example on line " & @ScriptLineNumber)

$iXLC_Debug = 2
Global $iTop
_ExcelWriteCell($aExcel[0], "", "B4:B5")                                            ; Clear all cells but one
$aExcel[1].SeriesCollection(1).HasErrorBars = True                                    ; Activate Error bars
$aExcel[1].SeriesCollection(1).ErrorBars.EndStyle = 2                                ; No cap: $xlNoCap
$aExcel[1].SeriesCollection(1).ErrorBar(1, $xlMinusValues, $xlPercent, 100)            ; Set error bars: ($xlY, $xlMinusValues, $xlPercent, 100)
$aExcel[1].SeriesCollection(1).ApplyDataLabels()                                    ; Apply the datalabels
$aExcel[1].SeriesCollection(1).DataLabels.Position = -4108                            ; Set the data labels centered: $xlLabelPositionCenter
_XLChart_LineSet($aExcel[1].SeriesCollection(1), Default, Default, False, Default, Default, $xlSheetHidden) ; Set series 1 to invisible
$aExcel[1].Legend.LegendEntries.Item(1).Delete()                                     ; Remove the legend entry for dataseries 1
_XLChart_LineSet($aExcel[1].SeriesCollection(1).ErrorBars, 1, 0x4A7EBB)                ; Set line color for the error bar
_XLChart_LineSet($aExcel[1].SeriesCollection(1).DataLabels, 1, 0)                    ; Set line color of the data label
_XLChart_FillSet($aExcel[1].SeriesCollection(1).DataLabels, 0x4A7EBB)                ; Fill the datalabel
$aExcel[1].SeriesCollection(1).Points(5).DataLabel.Text = "Test3"                    ; Set text of a point of the data label
$aExcel[1].SeriesCollection(1).Points(2).DataLabel.Text = "Test2"
$aExcel[1].SeriesCollection(1).Points(1).DataLabel.Text = "Test1" & @LF & "Next line"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#15 ·  Posted

Yep! It works well!

When I'll finish my charts I'll post a full example.

THANKS!

Share this post


Link to post
Share on other sites

#16 ·  Posted

I'm just writing the _XLChart_ErrorBarSet function. The next version of the UDF will have this function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#17 ·  Posted

One thing: error bars series is always in "background": both SeriesCollection(1) and SeriesCollection(n) are always set behind other series.

Share this post


Link to post
Share on other sites

#18 ·  Posted

You can change the plotorder of a data series within a chartgroup. It didn't work for the example - the markers of data series 2 always overwrite the errorbar.

Maybe this helps for your chart:

$aExcel[1].ChartGroups(1).SeriesCollection(2).PlotOrder = 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#19 ·  Posted

:) no way to set errorbar PlotOrder for now.

Share this post


Link to post
Share on other sites

#20 ·  Posted

Just for the records. When the error bars are moved to the secondary value axis they overwrite even the markers.

An example will follow!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2015-10-12 - Version 1.4.3.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

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

  • Similar Content

    • HSBen
      Excel UDF not attaching when multiple books open
      By HSBen
      If I have workbook open and active besides CardID.xlsm open, the script blows up.   Is there anyway to fix this, CardID.xlsm is always open, but if I want to also work in Excel my script basically doesn't function.
       
      Local $sWorkbook = "CardID.xlsm"
      $oWorkbook = _Excel_BookAttach($sWorkbook, "filename")
      $oWorkbook.parent.run("Run");
       
       
    • BrandonSanchez
      Incremental copy paste
      By BrandonSanchez
      Hello Autoit community

      I started using Autoit about 2 weeks ago and have found myself lost looking for information. Majority of the Help options are very easy to understand but I think that my general lack of knowledge about programming has slowed my progress. I tried very hard to not be that guy asking annoying questions on the forum but I’m afraid I’m out of options…

      The steps below are my attempt to explain my scenario

      Step 1: open excel file

      Step 2: Read range of Excel column “A1” – “A???”) The range of rows will vary from sheet to sheet.

      Step 3: take the values (one cell at a time) and place one value into my web browser ran program.

      Step 4: if that value has been added before (indicated by the PixelSearch) than delete (represented by the mouse click) and start the loop over moving onto the next cell.

      Step 5: if that value is new then submit the value (represented by the 2 mouse clicks at the end of the (if function)

      The code listed below is as far as I got. I hope this explanation will suffice and I look forward to any help I can get.


      (From WinActive(“Paste Too”) down is working as intended.)

       
    • broliukaz
      _ExcelReadCell() - undefined function ?
      By broliukaz
      Hi,
      Before I created my script with Windows 7 pro 32bit computer with Office 2013 32bit, and it's working on all my computers with Win7, Win8, Win10 with office 32 and 64bit...
      Now I want to edit it on Windows 10 pro 64bit Computer with Office 2016 64bit and I get error: _ExcelReadCell() - undefined function. Can this computer or office version cause the problem? Excel.au3 is included.
      Here is the part of my script:
      Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $xlsRepairs&$sItem) $CVDevice = _ExcelReadCell($oExcel, 1, 2) ; Device name $CVeqrma = _ExcelReadCell($oExcel, 3, 3) ; EQRMA Number $CVlot = _ExcelReadCell($oExcel, 5, 3) ; Lot number $CVpn = _ExcelReadCell($oExcel, 8, 3) ; PN $CVsn = _ExcelReadCell($oExcel, 11, 3) ; SN $CVreceived = _ExcelReadCell($oExcel, 17, 3) ; received $CVDevIdent = _ExcelReadCell($oExcel, 1, 2) ; Device identification $CVProjIdent = ($oExcel, 2, 2) ; Project identification _Excel_Close($oExcel)  
    • Chocolade
      AutoitX.ControlSend stopped working why ?
      By Chocolade
      I added to my project in c# referenced the dll's : AutoitX3.Assembly.dll and AutoitX3Lib.dll
      In my code i'm trying to simulate a combination of Ctrl + O
      So I did:
      AutoIt.AutoItX.ControlSend(processTitle, "", processFileName, "^^{r}"); When using a break point:
      In processTitle I see:  Game
      In the processFileName I see: C:\Program Files (x86)\Game\Game\Game.exe
      For checking I looked into Task Manager and there I see in the tab details: Game.exe as name and in Description I see Game
      And if I will click manually on my own Ctrl + O it will work it will do what I need it will take effect.
      But when using the AutoIt it will not work will do nothing no effect at all. And I see it's getting and doing the line with the ControlSend but nothing
      happen.
      And it did work few hours ago. What is wrong ?
       
    • xCobra15x
      Timer Help
      By xCobra15x
      Hi all, 
      I am looking for a quick tip on why my autoit script crashes when I run a timer. Currently I have this code:
            ....(more code above this)....
                Case $button2
                            function1()
                 Case $butTimer
                            _Timer_setTimer($hGUI, 3200, "_timedout")
              ......
               Func _timedout()
                             Msgbox(0, "Timed out", "Time is up!")
                Endfunc
      When the button is pressed, my timer starts, correct? It doesnt seem to matter if I have it on button activation or not, after the time goes by for a bit, it crashes.
      Seemingly when the time is up, my script crashes. 
      Thanks for your help!