简体   繁体   English

VB6中的ole excel对象

[英]ole excel objects in VB6

Is anyone aware of a good resource online for detailed information on the use of ole excel objects(embeded workbooks, worksheets, etc...) in VB6? 有人知道在线上有很好的资源来获取有关VB6中ole excel对象(嵌入式工作簿,工作表等)的使用的详细信息吗? I'm maintaining an application that makes heavy use of these conrols and I'm having a lot of trouble getting them to work properly for the user's of this program. 我正在维护一个大量使用这些控制的应用程序,但是让这些程序针对该程序的用户正常工作时遇到了很多麻烦。 The scattered bits of Q&A I can find online related to ole excel controls is very limited and not very definitive. 我可以在网上找到与ole excel控件相关的常见问题解答,内容很少,而且不是很确定。 Obviously, I have read through what there is on MSDN but I'm not finding it very helpful so I would like to find another good source of reference. 显然,我已经阅读了MSDN上的内容,但是我发现它没有什么帮助,因此我想找到另一个很好的参考来源。

Thanks 谢谢

I'm not sure this is helpful for embedding Excel, but assuming that the Excel engine is at the core of the embedded controls, you can look here for an alphabetized reference of the objects available for Excel 2003. 我不确定这是否对嵌入 Excel有帮助,但是假设Excel引擎是嵌入式控件的核心,则可以在此处查找可用于Excel 2003的对象的字母顺序引用。

And here for the root of the Excel VBA reference, which includes a section "Concepts" that discusses the major objects, like workbooks and worksheets, cells and ranges, etc. 这里是Excel VBA参考的基础,其中包括“概念”部分,其中讨论了主要对象,例如工作簿和工作表,单元格和范围等。

You'll have to set a reference to the Excel objects in your project before you can create any of these objects. 在创建任何这些对象之前,必须设置对项目中Excel对象的引用。 Under Project/References, you'll find something like "Microsoft Excel 9.0 Object Library." 在“项目/参考”下,您会找到类似“ Microsoft Excel 9.0对象库”的内容。 (I have Office 2000, thus the 9.0. Based on the links above, I imagine that for Excel 2003 you'll see Excel 11.) (我有Office 2000,也就是9.0。根据上面的链接,我想对于Excel 2003,您将看到Excel11。)

In your code, do something like this: 在您的代码中,执行以下操作:

' Start a new workbook in Excel '

Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook

' Launch an instance of Microsoft Excel '
Set oExcel = new Excel.Application
Set oBook = oExcel.Workbooks.Add

Then proceed to code against the application, workbooks, etc. The above code will create an instance of Excel that's not embedded, but in it's own window. 然后继续对应用程序,工作簿等进行编码。上面的代码将创建嵌入但在其自己的窗口中的Excel实例。 One thing to be aware of is that by default, that Excel instance will not be visible. 要注意的一件事是,默认情况下,该Excel实例将不可见。 You have to set the Visible property to True before you can see it. 您必须先将Visible属性设置为True才能看到它。

Hope this helps. 希望这可以帮助。

Any book on Excel VBA should help as you can copy and paste code from VBA to VB6. Excel VBA上的任何书籍都应该有所帮助,因为您可以将代码从VBA复制和粘贴到VB6。 I would start there. 我将从这里开始。

Also trying to do what you want to do in Excel with VBA then putting it into your VB6 project will also help. 另外,尝试使用VBA在Excel中完成您想做的事情,然后将其放入VB6项目中也将有所帮助。 Then you'll have access to all the VBA help in Excel (if you installed it.. it doesn't always install by default). 然后,您将可以访问Excel中的所有VBA帮助(如果已安装,则默认情况下并非总是安装)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM