473,666 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sFile Path) --> Throws Macro warning window
oExcel.Unprotec t("password")

Try
cnExcel.Open()
cnExcel.Close()
Catch ex As Exception
MsgBox(ex.Messa ge)
Finally
oExcel.Close()
End Try

Thanks,
-Rich
Nov 20 '05 #1
4 10093
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(sFile Path) --> Throws Macro warning window oExcel.Unprotec t("password")

Try
cnExcel.Open()
cnExcel.Close()
Catch ex As Exception
MsgBox(ex.Messa ge)
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*******@disc ussions.microso ft.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(sFile Path) --> Throws Macro

warning window
oExcel.Unprotec t("password")

Try
cnExcel.Open()
cnExcel.Close()
Catch ex As Exception
MsgBox(ex.Messa ge)
Finally
oExcel.Close()
End Try

Thanks,
-Rich
.

Nov 20 '05 #3
Rich,

Dim objExcel As Excel.Applicati on
Dim Books As Excel.Workbooks
Dim Book As Excel.Workbook
Dim Sheet As Excel.Worksheet

objExcel = New Excel.Applicati on
objExcel.Visibl e = True
Books = objExcel.Workbo oks

Book = Books.Open(file )

Sheet = CType(Book.Work sheets(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*******@disc ussions.microso ft.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(sFile Path) --> Throws Macro

warning window
> oExcel.Unprotec t("password")
>
> Try
> cnExcel.Open()
> cnExcel.Close()
> Catch ex As Exception
> MsgBox(ex.Messa ge)
> 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*******@disc ussions.microso ft.com> wrote in message
news:14******** *************** ******@phx.gbl. ..
Rich,

Dim objExcel As Excel.Applicati on
Dim Books As Excel.Workbooks
Dim Book As Excel.Workbook
Dim Sheet As Excel.Worksheet

objExcel = New Excel.Applicati on
objExcel.Visibl e = True
Books = objExcel.Workbo oks

Book = Books.Open(file )

Sheet = CType(Book.Work sheets(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*******@disc ussions.microso ft.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(sFile Path) --> Throws Macro
warning window
> oExcel.Unprotec t("password")
>
> Try
> cnExcel.Open()
> cnExcel.Close()
> Catch ex As Exception
> MsgBox(ex.Messa ge)
> 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
5920
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 VB.NET service - can't change the source Excel files. I can't seem to find a way to either globally disable macro execution or a property through the automation. Any ideas? Thanks, Scott
0
1359
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 control over the user's MS "security level"....which I think has tb set to "low" in order not to get a macro warning every time MS Access opens up a sheet. Per another thread, the "Certificate" route does not sound practical. Is there some...
1
3342
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 attachments... but our ..NET app needs to open as Read-Only and Disable Macros at all times. Is there a way to answer these questions programatically before opening the workbook? I'm also looking for any good references on the Excel object...
11
5284
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 a non-secure block of code defined alongwith it. Is there any way of disabling this macro...as mere #define _SECURE_ATL 0, in the stdafx.h or somewhere between the code is not working. Regards,
9
28823
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 message (...another program is attempting to automatically email...) that requires user intervention before the macro will finish execution. Can anyone advise me on how to disable the Outlook warning? I tried the Warnings Off function but realized it...
4
7947
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 out after googling for the last 3 days. I have written a large python script which inside of it creates an Excel table, the name of this file and how many objects can change for each project i run.
2
17712
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 from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
10
7779
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
17842
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 users reopen the file (equivalent of “Yes” on the warning box). Please guide me in the right direction. Thanks! Lena
0
8448
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.