Build Error
-
I'm having a strange problem declaring a NEW Excel.Application. I get a blue line under the line xlApp = New Excel.Application(). When I hover over the line the error states "'New' cannot be used on an interface.". I'm a little confused with the interface reference. I have referenced Excel, and MicrosoftOffice.Core and imported them on the page. The problem code is below. Imports Microsoft.Office Imports Excel Imports Microsoft.VisualBasic Imports Microsoft.Win32 Dim xlApp As Excel.Application Dim xlWB1 As Excel.Workbook xlApp = New Excel.Application() <----- Line with Error "'New' cannot be used on an interface." xlApp.Visible = True xlWB1 = xlApp.Workbooks.Open(strPath) xlWB1 = Nothing I am using the same code to open Word docs and PowerPoint presentations. Any suggestions would be very welcome. Thanks in advance
-
I'm having a strange problem declaring a NEW Excel.Application. I get a blue line under the line xlApp = New Excel.Application(). When I hover over the line the error states "'New' cannot be used on an interface.". I'm a little confused with the interface reference. I have referenced Excel, and MicrosoftOffice.Core and imported them on the page. The problem code is below. Imports Microsoft.Office Imports Excel Imports Microsoft.VisualBasic Imports Microsoft.Win32 Dim xlApp As Excel.Application Dim xlWB1 As Excel.Workbook xlApp = New Excel.Application() <----- Line with Error "'New' cannot be used on an interface." xlApp.Visible = True xlWB1 = xlApp.Workbooks.Open(strPath) xlWB1 = Nothing I am using the same code to open Word docs and PowerPoint presentations. Any suggestions would be very welcome. Thanks in advance
Interfaces contain no implementation so there is nothing to create. Are there no examples in the documentation of how to create an Excel application?
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
I'm having a strange problem declaring a NEW Excel.Application. I get a blue line under the line xlApp = New Excel.Application(). When I hover over the line the error states "'New' cannot be used on an interface.". I'm a little confused with the interface reference. I have referenced Excel, and MicrosoftOffice.Core and imported them on the page. The problem code is below. Imports Microsoft.Office Imports Excel Imports Microsoft.VisualBasic Imports Microsoft.Win32 Dim xlApp As Excel.Application Dim xlWB1 As Excel.Workbook xlApp = New Excel.Application() <----- Line with Error "'New' cannot be used on an interface." xlApp.Visible = True xlWB1 = xlApp.Workbooks.Open(strPath) xlWB1 = Nothing I am using the same code to open Word docs and PowerPoint presentations. Any suggestions would be very welcome. Thanks in advance
From: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2005_ta/html/officevstobuildingexcelinvoices.asp[^] It would appear that there is no . (dot) between Excel and Application. You should write
New ExcelApplication()
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
Interfaces contain no implementation so there is nothing to create. Are there no examples in the documentation of how to create an Excel application?
*** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
Thanks Angus for your thoughts, however your suggestion did not unfortunately work. In the same sub I have created a new word.application with the following syntax: Dim WordApp As Word.Application WordApp = New Word.Application() WordApp.Visible = True WordApp.Documents.Open(strPath) WordApp = Nothing The syntax above works perfectly, opening the word doc. Again thanks for your thoughts and ideas. SL Culbertson