ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can someone tell me what this means? (https://www.excelbanter.com/excel-programming/289449-can-someone-tell-me-what-means.html)

DennisE

Can someone tell me what this means?
 
I've got the usual references to Excel and VBA in Tools-References,
but to play it safe I replaced my Left( ), Right( ), Mid( ), Chr( ), Val( ),
and CVar( ) function calls by VBA.Left( ), ..., VBA.CVar( ) and all
went well. However, when I replaced the Len( ) function call where
it appeared in my code with VBA.Len( ) and then ran my program,
execution stopped at the occurrance of one of those lines of code
and displayed the following error message:

"Compile error: Ony user-defined types in public object modules can
be coerced to or from a variant or passed to late-bound functions"

Can anyone tell me what this means in plain English?

-- Dennis Eisen

Rob van Gelder[_4_]

Can someone tell me what this means?
 
Dennis,

Sounds like if you're modifying Left, Right etc.. to VBA.Left then you may
have some broken references.
Check Tools | References for MISSING:
But that's unrelated to your problem...

I've had the error message before. I think it had something to do with a
trying to convert a User Defined Type to a Variant.

This example gives the same error, which can be fixed by declaring var as
mytype:

Type mytype
teststring As String
End Type

Sub test()
Dim var As Variant, udt As mytype

var = udt
End Sub


Rob



"DennisE" wrote in message
...
I've got the usual references to Excel and VBA in Tools-References,
but to play it safe I replaced my Left( ), Right( ), Mid( ), Chr( ),

Val( ),
and CVar( ) function calls by VBA.Left( ), ..., VBA.CVar( ) and all
went well. However, when I replaced the Len( ) function call where
it appeared in my code with VBA.Len( ) and then ran my program,
execution stopped at the occurrance of one of those lines of code
and displayed the following error message:

"Compile error: Ony user-defined types in public object modules can
be coerced to or from a variant or passed to late-bound functions"

Can anyone tell me what this means in plain English?

-- Dennis Eisen





All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com