Convert Excel macro to OO Basic macro

Creating a macro - Writing a Script - Using the API

Convert Excel macro to OO Basic macro

Postby othmanelmoulat » Wed Aug 20, 2008 1:11 pm

Hi,
I need help converting below Excel macro to OOBasic macro .
my knowledge in OObasic macros is very "Basic" ; so i appreciate your help on this guys .


Code: Select all   Expand viewCollapse view
Sub AddChartObject()
  Dim myChtObj As ChartObject

  Set myChtObj = ActiveSheet.ChartObjects.Add _
                 (Left:=50, Width:=575, Top:=90, Height:=275)

  Set objSheet = Worksheets("audusd.xls")
  intOffsetX1 = 1575
  intOffsetX2 = 1740

  With myChtObj
    ' Add the 4 series for the candles stick
    For i = 1 To 4
      With .Chart.SeriesCollection.NewSeries
        .Name = objSheet.Cells(1, i + 1)
        .Values = objSheet.Range(objSheet.Cells(intOffsetX1, i + 1), objSheet.Cells(intOffsetX2, i + 1))
        .XValues = objSheet.Range(objSheet.Cells(intOffsetX1, 1), objSheet.Cells(intOffsetX2, 1))
      End With
    Next i

    .Chart.ChartType = xlStockOHLC
    With .Chart.ChartGroups(1)
      .HasUpDownBars = True
      .DownBars.Interior.ColorIndex = 3
      .UpBars.Interior.ColorIndex = 5
    End With

    aryColorIndex = Array(1, 5)
    For i = 1 To 2
      With .Chart.SeriesCollection.NewSeries
        .Name = objSheet.Cells(1, i + 5)
        .Values = objSheet.Range(objSheet.Cells(intOffsetX1, i + 5), objSheet.Cells(intOffsetX2, i + 5))
        .XValues = objSheet.Range(objSheet.Cells(intOffsetX1, 1), objSheet.Cells(intOffsetX2, 1))
        .ChartType = xlLine
        .Border.Weight = xlHairline
        .Border.ColorIndex = aryColorIndex(i - 1)
      End With
    Next i
  End With
End Sub
OOo 3.4 and LibreOffice 3.4 on openSuse 11.4 + windows 7
othmanelmoulat
 
Posts: 142
Joined: Sun Aug 03, 2008 4:39 am

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests