Dump Trading Table (O2GO, VBA)

From FxCodeBaseWiki
Jump to: navigation, search

The example writes the content of the Offers table to the first sheet of the Excel workbook.

To use the example:

  1. Create a new workbook
  2. Go To the Visual Basic For Application project (Alt-F11)
  3. Add Reference to Order2Go to your project
  4. Go To the ThisBook section of the project
  5. Paste the example code there
  6. Fill USR, PWD, CONN and URL variables with the parameters of the connection you use for the Trading Station
  7. Run ExportOffers function


Const USR = "username"
Const PWD = "password"
Const CONN = "Demo"
Const URL = "http://www.fxcorporate.com"

Sub ExportOffers()
    Dim core As FXCore.CoreAut
    Dim desk As FXCore.TradeDeskAut
    Dim offers As FXCore.TableAut
    Dim columns As FXCore.ColumnsEnumAut
    Dim column As FXCore.ColumnAut
    Dim sheet As Worksheet
    Dim i As Long
    Dim j As Long
    
    Set sheet = ActiveWorkbook.Worksheets.Item(1)
    
    Set core = New FXCore.CoreAut
    Set desk = core.CreateTradeDesk("trader")
    Call desk.Login(USR, PWD, URL, CONN)
    Set offers = desk.FindMainTable("offers")
    Set columns = offers.columns
    For i = 1 To offers.ColumnCount
        Set column = columns.Item(i)
        sheet.Cells(1, i).Value = column.Title
    Next i
    For i = 1 To offers.RowCount
        For j = 1 To columns.Count
            sheet.Cells(i + 1, j).Value = offers.CellValue2(i, j)
        Next j
    Next i
    Call desk.Logout
End Sub

See also: Visual Basic For Application (O2GO)

This Article in Other Languages

Language: English  • español