Question : Vb 2008 and Microsoft.Office.Interop.Excel error

I have a project and i add the excel reference to export some data to excel. The problem is that after i add "Imports Microsoft.Office.Interop.Excel" i get a lot of error in the source: for example when i change the font of a datagridview with:
        Dim font As New Font(DgViewMain.DefaultCellStyle.Font.FontFamily, 6, FontStyle.Italic)
        Try
            DgViewMain.Rows(Me.DgViewMain.CurrentRow.Index).DefaultCellStyle.Font = font
        Finally
            font.Dispose()
        End Try
The word new is in error: "New cannot be used in an interface"
I have the some error on:
DgViewComR.Location = New Point(DgViewComT.Location.X + DgViewComT.Width + 5, DgViewKit.Location.Y + DgViewKit.Height + 5)
The error is the same "New ...."
Where is my error?
Thanks

Answer : Vb 2008 and Microsoft.Office.Interop.Excel error

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel(office.11).aspx

The reason you got the error after adding the "Imports" statement is that the Microsoft.Office.Interop.Excel Namespace also contains a FONT and a POINT.  Before you added that, Visual Studio knew that you wanted to use the System.Drawing namespace...once you added the imports, it wasn't sure anymore, so now you have to tell it what you want.

Random Solutions  
 
programming4us programming4us