It is always useful to tell the line that gives you the error...
My guess is that you didn't include the Excel object library into your project.
Go to the Project Menu, Select References at the bottom of this menu and when they show up check the box for Microsoft Excel xx Object Library _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]