VBA error file not found - need help using new aspects of VBA

MeltManBob

New Member
Joined
Apr 3, 2013
Messages
7
Hey guys I've messed with VBA a bit in the past but never to connect to a site to get information or using an API or COM. I'm trying to get historical Forex data from FXCM. They have a Forexconnect API and COM, both of which I've installed as instructed and enabled the fxcore2_com reference in the VBA editor. The COM comes with sample excel files and the one I'm trying to use and having problems with is the Login.xls. This is the code in that file:

Code:
Option Explicit


Dim transport As transport
Dim WithEvents session As session
Dim LastSessionStatus As fxcore2_com.SessionStatusCode


Public Sub Login()
    Call CheckState
    If LastSessionStatus = SessionStatusCode_Connected Then
        Range("Info").Value = "Please logout at the first"
        Exit Sub
    End If
    'force login
    If Range("Login").Value = "" Or Range("Password").Value = "" Then
        Range("Info").Value = "Please provide login and password"
        Exit Sub
    End If
    Call session.Login(Range("Login").Value, Range("Password").Value, Range("URL").Value, Range("Connection").Value)
    Range("Info").Value = "Logged in..."
        
End Sub


Public Sub Logout()
    If LastSessionStatus <> SessionStatusCode_Connected Then
        Range("Info").Value = "Please login at the first"
        Exit Sub
    End If
    Call session.Logout
End Sub


Private Sub Worksheet_Activate()
    On Error GoTo Catch
    Call CheckState
    Exit Sub
Catch:
    MsgBox Err.Description
End Sub


Private Sub CheckState()
    If transport Is Nothing Then
        Set transport = CreateObject("fxcore2.com.Transport")
        
        'create session
        Set session = transport.createSession()
        Range("Status").Value = GetStatusName(LastSessionStatus)
    End If
End Sub


Private Sub Worksheet_Deactivate()
    On Error Resume Next
    Set session = Nothing
    Set transport = Nothing
End Sub


Private Sub session_SessionStatusChanged(ByVal status As SessionStatusCode)
On Error GoTo Catch
    Range("Status").Value = GetStatusName(status)
    Range("Info").Value = ""
    LastSessionStatus = status
    Exit Sub
Catch:
    MsgBox Err.Description


End Sub


Private Sub session_SessionStatusLoginError(ByVal error As String)
    Range("Info").Value = error
End Sub


Private Function GetStatusName(status As SessionStatusCode)
    Select Case status
        Case SessionStatusCode_Connected
            GetStatusName = "connected"
        Case SessionStatusCode_Disconnected
            GetStatusName = "disconnected"
        Case SessionStatusCode_Connecting
            GetStatusName = "connecting"
        Case SessionStatusCode_TradingSessionRequested
            GetStatusName = "trading session requested"
        Case SessionStatusCode_Disconnecting
            GetStatusName = "disconnecting"
        Case SessionStatusCode_SessionLost
            GetStatusName = "session lost"
        Case SessionStatusCode_PriceSessionReconnecting
            GetStatusName = "price session reconnecting"
        Case SessionStatusCode_Unknown
            GetStatusName = "unknown"
        Case Else
            GetStatusName = CStr(status)
    End Select
End Function

When I run the Login routine I get an automation error. When put the cursor in front of "Public Sub Login()" and hit the play button, I get:

Run-time error '-2147024894 (80070002)':
Automation error
The system cannot find the file specified

I get this same error when I choose "run to cursor" and the cursor is placed in front of "If LastSessionStatus = SessionStatusCode_Connected Then"

Can anyone tell me what is going on with this?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,203,380
Messages
6,055,099
Members
444,762
Latest member
MRC3411

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top