Excel operations, error 80040154

Source: Internet
Author: User

From the help post of dg97112c, I encountered the same problem and saw that this post solved it.

Post address: http://topic.csdn.net/u/20110428/09/aa420af6-670b-4d5e-9e3c-02a45df488dd.html

Problem:

Vs2010 + office2003

The referenced
When output, the following message is displayed:
Retrieving components whose CLSID is {00020819-0000-0000-c000-000000000046} in the com class factory failed because of the following:
Error: 80040154 no registered category (exception from hresult: 0x80040154 (regdb_e_classnoregulatory )).

I have found many ways to configure DCOM on the Internet. The problem is still the same. The Office is also reinstalled, and changing to Office XP and Office2000 is the same problem.

 

Solution:

Original code:
Dim xlapp as new excel. Application
Dim xlbook as new excel. Workbook
Dim xlsheet as new excel. Worksheet

I found the problem. When I defined xlbook and xlsheet, I used new. Khan, too careless to look at other people's programs. I thought there was new.
The correct statement is as follows:
Dim xlapp as new excel. Application
Dim xlbook as Excel. Workbook
Dim xlsheet as Excel. Worksheet
Xlbook = xlapp. workbooks. Open ("C: \ 1.xls ")
Xlsheet = xlbook. worksheets (1)
I have seen many such errors on the Internet. I don't know if they are all my mistakes. Hope to have a group for you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.