Variable uses an Automation type not supported in Visual Basic

مؤمّن Variable uses an Automation type not supported in Visual Basic

  • giovedì 12 luglio 2012 08:53
     
     

    Hi everyone,

    I have created a com library using visual studio 2010 and have referenced(called) it from Excel VBA.

    The dll function takes three input variables and returns a userdefined structure type "DataSetForCOM" array as output.

    Dim Local As testclass.Class1
    Set Local = New testclass.Class1

    Dim Results() As testclass.DataSetForCOM

    Results = Local.dll_main(a, b, c)

    Initially it worked fine and later when i have made some modifications to my dll code and have created a new class library, i have received the error "Variable uses an Automation type not supported in Visual Basic " pointing at the line

    Dim Results() As testclass.DataSetForCOM

    The modifications include changing the output structure type.

    This is the original datastructure:

     Public Structure COM_PhiDataSet

            Dim RefGrid As Integer
            Dim Refcase() As String
            Dim Index() As Double
            Dim Value() As Double

        End Structure

    NEW data structure:

        Public Structure PhiDataSetForCOM

            Dim RefGrid As Integer
            Dim Refcase As String
            Dim Index As Double
            Dim Value As Double

        End Structure

    I couldn't figure out what can be the problem, as the variable types of the data structure elements are same as in the previous one and are accepted by visual basic. Can anyone please help me out with this?

    Thnx n R'gds

    Karthik

Tutte le risposte

  • venerdì 13 luglio 2012 03:23
    Moderatore
     
     Con risposta

    Hi Karthik,

    Welcome to the MSDN forum.

    This error will be caused by you trying to use a variable defined in a type library or object library that has a data type not supported by Visual Basic.

    My suggestion is set the “Option Explicit” on at the top of your code and force explicit declaration of all variables and check whether has variables not support by VB.

    By the way, if you encounter this error while using FileGet or FileGetOBject, make sure the file you are trying to use was written to with FilePutor FilePutObject.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

  • martedì 24 luglio 2012 05:36
    Moderatore
     
     

    Hi Karthik,

    We haven’t heard from you for several days. I’d like to mark my reply as answer firstly. If you have any additional questions, you also can unmark the replay and post your question here.

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us