Rich,
Dim objExcel As Excel.Application
Dim Books As Excel.Workbooks
Dim Book As Excel.Workbook
Dim Sheet As Excel.Worksheet
objExcel = New Excel.Application
objExcel.Visible = True
Books = objExcel.Workbooks
Book = Books.Open(file)
Sheet = CType(Book.Worksheets(1), Excel.Worksheet)
DirectCast(Book.Sheets("Sheet1"),
Excel.Worksheet).Activate()
Sheet = DirectCast(Book.ActiveSheet, Excel.Worksheet)
Jorge
-----Original Message-----
Forgive me, what namespace do I use to access the Books
class?
"Jorge" <an*******@discussions.microsoft.com> wrote in
messagenews:13*****************************@phx.gbl... Hello Rich
I use the following approach Book = Books.Open(file)
and i never recived any macro warning.
Kind Regards
Jorge
>-----Original Message-----
>Is there a way to open an Excel file and either
respond to or supress the >Macro warning window via VB.NET?
>
> Dim oExcel As Excel.Workbook
>
> Dim sFilePath As String = "C:\DailyReport.xls"
>
> oExcel = GetObject(sFilePath) --> Throws Macro
warning window > oExcel.Unprotect("password")
>
> Try
> cnExcel.Open()
> cnExcel.Close()
> Catch ex As Exception
> MsgBox(ex.Message)
> Finally
> oExcel.Close()
> End Try
>
>Thanks,
>-Rich
>
>
>.
>
.