missmemberexception的错误未得到处理 [英] Error of missingmemberexception was unhandled

查看:84
本文介绍了missmemberexception的错误未得到处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel


        Select Case ComboBox1.SelectedItem

            Case "Open Excel"

                Dim oExcel As New Microsoft.Office.Interop.Excel.Application()
                Dim oBook As Excel.WorkbookClass
                Dim oBooks As Excel.WorkbookClass

                'Start Excel and open the workbook
                oExcel.Visible = True
                'oBooks = oExcel.Workbooks

                oExcel = oExcel.Open("H:\Copy of Book1.xlsm")

                'Run the subroutine.
                oExcel.Run("Sheet1")





你好,我在



Hello, I have an error of MissingMemberException was unhandled after I run the code at

oExcel = oExcel.Open("H:\Copy of Book1.xlsm")





我如何解决这个问题?谢谢!!



我尝试了什么:



我有尝试添加引用,如Microsoft Office Excel



How do I solve this problem? Thank you!!

What I have tried:

I have tried adding references such as Microsoft Office Excel

推荐答案

您无法以您尝试这样做的方式打开工作簿。你必须通过工作簿的集合来做到这一点:

You can't open workbook the way you're trying to do that. You have to do this through the collection of workbooks:
oBook = oExcel.Workbooks.Open("H:\Copy of Book1.xlsm")





进一步详情请见:

如何:以编程方式打开工作簿 [ ^ ]

Excel对象模型概述 [ ^ ]


这篇关于missmemberexception的错误未得到处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆