Results 1 to 2 of 2

Thread: [RESOLVED] here's one for the purists

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    27

    Resolved [RESOLVED] here's one for the purists

    I have a button click event handler where an array QQ gets populated with Single values & I open a new Excel workbook & try to dump the values of QQ into it :

    VB Code:
    1. Private Sub button_Click()
    2.  
    3. Dim QQ() As MyType
    4. ReDim QQ(3)
    5.  
    6. '...
    7. 'QQ gets populated correctly here...
    8. '...
    9. Set oXLApp = New Excel.Application
    10. oXLApp.Visible = True
    11. Set oXLBook = oXLApp.Workbooks.Add
    12. Set oXLSheet = oXLBook.Worksheets(1)
    13.  
    14. oXLSheet.Range("A1:E9").Value = QQ
    15. ...
    16. end Sub

    where MyType is defined as

    VB Code:
    1. Private Type MyType
    2.     lZero As Single
    3.     lOne As Single
    4.     lTwo As Single
    5.     lThree As Single
    6. End Type

    I get compiler error :
    "only UDTs defined in public object modules can be coerced to or from a variant or passed to late-bound functions"

    What does this mean ??
    I tried changing the button_Click() subroutine from Private to Public, but still get the same error. I would much rather understand the source of the problem than try to blindly correct it.

    thanks,

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: here's one for the purists

    MyType has to be declared in a module. Go to the Visual Basic editor. right-click on This Workbook. Go to Insert. Select Module. Declare the public Type MyType there.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width