Disable Excel Macro warning?

  • Thread starter Thread starter Rich Wallace
  • Start date Start date
R

Rich Wallace

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
 
Hello Rich
I use the following approach Book = Books.Open(file) and
i never recived any macro warning.

Kind Regards
Jorge
 
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
 
Back
Top