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" <(E-Mail Removed)> wrote in
message
>news:134bf01c3f7ca$3d9b53b0$(E-Mail Removed)...
>> 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
>> >
>> >
>> >.
>> >
>
>
>.
>
|