By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,367 Members | 1,780 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,367 IT Pros & Developers. It's quick & easy.

Disable Excel Macro warning?

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 theMacro 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
.

Nov 20 '05 #2

P: n/a
Forgive me, what namespace do I use to access the Books class?

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news: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
.

Nov 20 '05 #3

P: n/a
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
>
>
>.
>

.

Nov 20 '05 #4

P: n/a
Duh. Sorry about that. That worked like a champ!!!

Thank you sir!

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:14*****************************@phx.gbl...
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

message
news: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
>
>
>.
>

.

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.