Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Excel Charts


  • Please log in to reply
33 replies to this topic
hot hot 85
  • Members
  • 72 posts
  • Last active: Sep 29 2015 05:40 AM
  • Joined: 27 Jun 2011

Pretty cool script
 
 I run it and show this :
 
 
---------------------------
New AutoHotkey Script (6).ahk
---------------------------
Error:  0x8002000B - Invalid index.
 
Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0
 
Specifically: Worksheets

 
Line#
012: XL.Range("B4").Value := 21  
014: XL.Range("A1:B4").Select  
015: XL.ActiveSheet.Shapes.AddChart.Select  
016: XL.ActiveChart.ChartType := 63  
017: XL.ActiveChart.PlotArea.Select  
018: XL.ActiveChart.SetElement(207)  
019: XL.Range("A1").Select  
---> 021: XL.Worksheets("Sheet1").ChartObjects(1).Chart.Export("C:\pic1.bmp")  
023: XL.ActiveWorkbook.Close(0)  
024: XL.Quit  
026: Gui,Add,Picture,,C:\pic1.bmp
027: Gui,Show
028: Return
029: Exit
030: Exit
 
Continue running the script?
---------------------------
Yes   No   
---------------------------

 

any Ideas?

 

thanks

 I found  the error , the version of office is in spanish , and show an error. I change to english and works fine :)

 

I try to used this in spanish but I can figure it out  

 

xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)

 

http://stackoverflow...disp-e-badindex

 

thanks in advance


Every day exist something new to learn

Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

 I found  the error , the version of office is in spanish , and show an error. I change to english and works fine :)

 

I try to used this in spanish but I can figure it out  

 

xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)

 

http://stackoverflow...disp-e-badindex

 

thanks in advance

 

I was having the same problem, I just fixed with this:

 

XL.WorkSheets(1).ChartObjects(1).Chart.Export("C:\pic1.bmp")



capbat
  • Members
  • 191 posts
  • Last active: Feb 08 2017 06:57 PM
  • Joined: 29 Nov 2007

Hi All

Has anyone thought of using this dynamically ie: with a variable amount of data?

 

Thanks.

 

Bat 



jakupmichaelsen
  • Members
  • 6 posts
  • Last active: Dec 20 2015 09:59 PM
  • Joined: 27 Dec 2014

Great find and awesome examples! :)

 

I just finished the following function, which takes an array on creates a radar chart:

 

 

----

; Pass a simple or associative array to this function to have it return a radar chart. 
;
; Example:
; Simple array: myArray := [3, 5, 3, 2, 1, 5, 3, 4, 2]
; Associative array:  myArray := {"Thesis": 3, "Introduction": 4, "Conclusion": 1, "Sentences": 2, "Organization": 3}
radarChart(myArray)
 
 
radarChart(myArray) { 
xl := ComObjCreate("Excel.Application") ; Excel object 
xl.WorkBooks.Add ; Add workbook (invisible)
 
for index, element in myArray ; Loop through the array
{
   xl.Cells(A_Index, 1).Value := index ; Column A = index ; In simple arrays, This will just be sequential numbers 
   xl.Cells(A_Index, 2).Value := element ; Column B = element 
}
 
xl.ActiveCell.CurrentRegion.Select ; Select current region of cells 
xl.ActiveSheet.Shapes.AddChart.Select ; Add chart 
xl.ActiveChart.ChartType := 82 ; Radar chart 
xl.ActiveChart.ClearToMatchStyle 
xl.ActiveChart.ChartStyle := 11 
xl.ActiveChart.ClearToMatchStyle
 
xl.Worksheets(1).ChartObjects(1).Chart.Export("C:\pic1.png") ; Save as PNG 
 
xl.ActiveWorkbook.Close(0) 
xl.Quit ; Quit Excel
 
Gui, Add, Picture, , C:\pic1.png ; Simple GUI for showing image 
Gui, Show
}