Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default VBA Reference to Custom tlb

I have a dll which I generated a tlb for and am referencing that tlb
from VBA in Excel (2003). When I try to create and use any custom
defined typedef, I get a "Variable uses an Automation type not supported
in Visual Basic" on compilation. For example, this from the tlb:

struct tagPageDimension {
LPSTR dimensionName;
LPSTR MemberName;
} PageDimension;

then this line in the VBA causes the error:

Dim oTemp As MyClass.PageDimension

Additionally, on the intellisense, I don't get the members when I then do:
oTemp. (dimensionName and MemberName should come up but don't)

Can anyone help?
thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default VBA Reference to Custom tlb

Hi Matthew,

It will be appreciated you let me know what scneario you are at now: from C++ to VB or from .Net to VB.

If from .Net to VB, I assume you are using C# language and the structure definition may be as below:
public structure PageDimension{
public string dimensionName;
public string MemberName;
}

From the inteoped typelibrary, the definition for this structure is the same to yours:
struct tagPageDimension {
LPSTR dimensionName;
LPSTR MemberName;
} PageDimension;

From my test, in VB, the member of this structure can't be retrieved. However, I'd suggest you can use Class instead of the structure here. This
way, you can get the dimensionName and MemberName in VB after the interop.

Look forward to your confirmation on whether your scenario locates at managed scenario or un-managed scenario! Then we can perform further
research for you on this issue. Expect to your reply!

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default VBA Reference to Custom tlb

It is from .NET (C#).

Wei-Dong XU [MSFT] wrote:
Hi Matthew,

It will be appreciated you let me know what scneario you are at now: from C++ to VB or from .Net to VB.

If from .Net to VB, I assume you are using C# language and the structure definition may be as below:
public structure PageDimension{
public string dimensionName;
public string MemberName;
}

From the inteoped typelibrary, the definition for this structure is the same to yours:
struct tagPageDimension {
LPSTR dimensionName;
LPSTR MemberName;
} PageDimension;

From my test, in VB, the member of this structure can't be retrieved. However, I'd suggest you can use Class instead of the structure here. This
way, you can get the dimensionName and MemberName in VB after the interop.

Look forward to your confirmation on whether your scenario locates at managed scenario or un-managed scenario! Then we can perform further
research for you on this issue. Expect to your reply!

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default VBA Reference to Custom tlb

Hi Matthew,

From my research, VB doesn't support struct*. It supports BSTR type for the string.

So I'd suggest please change the codes as this in the C# component:

public struct PageDimension
{

[MarshalAs(UnmanagedType.BStr)]
public string dimensionName;

[MarshalAs(UnmanagedType.BStr)]
public string MemberName;
}

Then, tlbexp the assembly to generate the TLB. In my case,
Tlbexp StructInterop.dll /out:mystruct.tlb

In the VB6 side, do this:

Dim myStruct As StructInterop.PageDimension

myStruct.dimensionName = ¡°test¡±
myStruct.MemberName = ¡°this¡±

It works very well!

Please feel free to let me know if you have any further questions.

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Format Cell with Reference to another sheet enna49 Excel Worksheet Functions 2 January 7th 10 06:13 AM
getpivotdata custom subtotal cell reference anna_717717 Excel Worksheet Functions 3 February 11th 09 05:30 PM
relative cell reference in custom validation GoBobbyGo Excel Discussion (Misc queries) 2 April 24th 06 11:17 PM
Cell reference in the auto filter custom list Andre Croteau Excel Discussion (Misc queries) 1 February 14th 06 02:03 PM
Reference Cell in custom format???? lil_ern63 Excel Discussion (Misc queries) 3 September 1st 05 02:27 PM


All times are GMT +1. The time now is 06:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"