【发布时间】:2009-07-29 14:16:29
【问题描述】:
我正在尝试使用 VBA 可扩展互操作从 c# 中查找 msform 上的所有控件。
我可以使用 :
找到所有表格using System;
using Microsoft.Office.Interop.Excel
using Microsoft.Vbe.Interop;
using Microsoft.Vbe.Interop.Forms;
.....
foreach (Microsoft.Vbe.Interop.VBComponent mycom in wb.VBProject.VBComponents)
{
if (mycom.Type == Editor.vbext_ComponentType.vbext_ct_MSForm)
.....
但我在该表单上找不到控件。
我认为它应该看起来像:
....
foreach (Microsoft.Vbe.Interop.Forms.Control ctrl in Microsoft.Vbe.Interop.VBComponent.Designer.Controls)
....
但无法识别 Controls 集合。
有什么想法吗?
此线程提供了有关我面临的问题的更多信息:
【问题讨论】:
-
我认为这个问题归结为继承和互操作。 “通用”设计器对象应从表单互操作中继承控件对象。似乎 vb.net 会自动进行此转换...但我不知道如何!!!