Click on File and click on New Project. Under Visual basic,Select “Windows” and then select “Windows Form Application”. Give the project an appropriate name and select a location where you want to save this project.
When the project opens you will be presented with Form1. For the time being just lets create 3 buttons and name then “Create”,“Open”,“Cancel”. Give an appropriate heading to the form. Your form should look like this.
Now let’s set references for Excel in our project. For this click on the menu Project~~>Add Reference. You will be presented with a “Add Reference”-dialog Box. Navigate to the “COM” Tab and select the Microsoft Excel Object Library.
After setting the reference,double click on any of the button to open the Form1 Code Area and paste this line of code at the very top.
Imports
Excel = Microsoft.Office.Interop.Excel
|
Microsoft.Office.Interop.Excel
Microsoft.Office.Tool.Excel
将这些都加入进来
Double-click on the third button “Cancel” and paste the code. This is how your code should look like.
And you are all set for automating Excel From VB.Net.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。