lundi 20 avril 2015

Selecting Range for Excel chart in VBScript

I have two questions:
1. If we can pass an array to VBSCript using java. I am able to pass single variables to VBSCript using following command

Runtime.getRuntime().exec("wscript openChartsDevice.vbs " + fileName + " " + range);

But when I pass a String array, it says type mismatch. I am catching the array passed in

Dim arr()

any Suggestions?

2. I am using following Vbscript to create chart in excel

    Dim oExl,excelPath,objWriteSheet,objWriteWorkbook
    Dim oMychartProcs
    Set oExl=CreateObject("Excel.Application")
    Set objWriteWorkbook = oExl.Workbooks.Open("SomeExcelfile.xlsx")
    Set objWriteSheet = objWriteWorkbook.Worksheets(1)
    Set oMychartProcs = objWriteWorkbook.Charts.Add
    oMychartProcs.SetSourceData objWriteSheet.Range(Cells(2,1),Cells(7,6))
    oMychartProcs.ChartType = 4
    oMychartProcs.Name = "ChartName"
    oMychartProcs.Activate

I have given the range as A2:F7. when I enter

oMychartProcs.SetSourceData objWriteSheet.Range("A2:F7")

the chart is created perfectly but when I use the

 Range(Cells(2,1),Cells(7,6))

whole excel sheet is converted to chart. I want to provide the range through parameters so I want above formula to work. I've searched a lot and could not find a definitive way for it. Thank you.

Aucun commentaire:

Enregistrer un commentaire