Excel VBA script to import CSV data

Hello all,
I’m trying to automate Amibroker database update via VBA script within Excel. Inspired by this post in Amibroker YG:
https://www.mail-archive.com/amibroker@yahoogroups.com/msg45323.html

I’m also referring to this post about using JavaScript to import CSV into database:

I have the below script

Sub ABData()
'https://www.mail-archive.com/amibroker@yahoogroups.com/msg45323.html
    Dim Amibroker As Object
    
    Set Amibroker = CreateObject("Broker.application")    
    AmiBroker.Import(0,"E:\Intraday.csv", "custom1.format")
    Amibroker.RefreshAll

    Set ActiveDoc = Nothing
    Set Amibroker = Nothing

End Sub

I got error when coming to the Amibroker.Import line. The error says “=” is expected.

Appreciate any guides from the experienced here.

thanks.

1 Like

Import() is a function so I guess your Vsual Basic needs assignment.

result = AmiBroker.Import(...

We really recommend using JScript as syntactically it is similar to AFL.

1 Like

Thanks TJ for you reply. Somebody has also PMed me another way to achieve this by adding ‘Call’ in front of the Amibroker.Import() function.

Sub ABData()
Dim Amibroker As Object

Set Amibroker = CreateObject("Broker.application")    
Call Amibroker.Import(0,"E:\Intraday.csv", "custom1.format")
Call Amibroker.RefreshAll

Set Amibroker = Nothing


End Sub

Thanks TJ for javascript recommendation, I notice that almost everyone are using js here.
I already have a spreadsheet set up as my ‘dashboard’. so just exploring the possibility to reach Amibroker via a button in excel. As expected, it is achievable. Amibroker is superb!

Is there a way to run or call a javascript from within Excel VBA? That would be awesome!

3 Likes

I too would be interested in knowing how to achieve this please. :grinning:

You can read more about creating and using MS object called MSScriptControl.ScriptControl

1 Like