Forum Discussion

mjvdlugt's avatar
mjvdlugt
Copper Contributor
Jul 21, 2023

Variable uses an Automation type not supported in Visual Basic

In Excel (MAC version)

 

I have programmed a simple Class module:

 

Option Explicit

Public Sub Init( _

Optional ByVal xID, _

Optional ByVal xName, _

Optional ByVal xISIN, _

Optional ByVal xAssetCurrency, _

Optional ByVal xCountry, _

Optional ByVal xIncomeAccount,

Optional ByVal xCapitalAccount, _

Optional ByVal xCeasedDate)

 

End Sub

 

When calling this Class by

 

Sub test()

Dim asset As CAsset

Set asset = New CAsset

asset.Init

End Sub

 

I get an error 456 message: "Variable uses an Automation type not supported in Visual Basic"

 

Does anyone know how to resolve?

1 Reply

  • mjvdlugt 

    You're missing a line continuation character _ after xIncomeAccount,

    It should be

    Public Sub Init( _
        Optional ByVal xID, _
        Optional ByVal xName, _
        Optional ByVal xISIN, _
        Optional ByVal xAssetCurrency, _
        Optional ByVal xCountry, _
        Optional ByVal xIncomeAccount, _
        Optional ByVal xCapitalAccount, _
        Optional ByVal xCeasedDate)
    
    End Sub

    With that change, the Test macro runs without error on my PC.

Resources