473,414 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Disable Excel Macro warning?

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
4 10082
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott Wallace | last post by:
Anyone know how to disable macros when access an Excel file through automation? I have an Excel file that fires macros when it is opened. I need to automate reading values from the file through a...
0
by: (Pete Cresswell) | last post by:
I'm writing a loop that Dir$'s through about a hundred MS Excel spreadsheets and extracts info from maybe 5-20 workbooks within each into a staging table. Problem is that I don't think I have any...
1
by: Troy | last post by:
How do I answer the disable macro prompt automatically when opening an Excel workbook? We are using Excel 97 and 2002. In 2002 we want the Medium security (prompt user) to safeguard against e-mail...
11
by: Ejaz ul Haq | last post by:
Dear All, I have upgraded my source code from VS 2003 to VS 2005, and my code is breaking due to the _SECURE_ATL macro in some methods of ATL. As it is executed all the times though there is also...
9
by: JBuckner | last post by:
My macro uses the Send Object (VBA Item.Send) function to email a spreadsheet to an Outlook contact list. I want the function to be completely automatic but Outlook displays a security warning...
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
10
by: Stephen Plotnick | last post by:
I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a page break before line 72. I've tried several ways but always get an exception error. Thanks in advance.
8
newnewbie
by: newnewbie | last post by:
Hi, How do I disable the warning Excel gives me when I am trying to open a document with the same name? I do not care is the changes are discarded, just need to switch the warning off and let the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.