Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Alter macro security level programmatically

I have an Access application that is opening a number of Excel spreadsheets
and reading data from them. Each of these spreadsheets has the same macros,
which I want to disable when I open the workbook, rather than having to click
the pop-up window that asks if I want to enable/disable macros.

Is there a way to do this using Excel automation? How about using API
calls? My intent is that I would like to read the current setting, change
the setting to disable macros, read in the files, then reset the setting to
its original value.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Alter macro security level programmatically

You may be able to adapt this to Access:

Sub is_it_safe()
Dim s As String
Dim s2 As String
s2 = "C:\temp\child1.xls /s"
s = "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.exe "
x = Shell(s & s2, 1)
End Sub

The idea is to open child1.xls in Excel in Office Safe Mode. This should
disable any child1 startup macro activity.
--
Gary''s Student - gsnu200764


"Dale Fye" wrote:

I have an Access application that is opening a number of Excel spreadsheets
and reading data from them. Each of these spreadsheets has the same macros,
which I want to disable when I open the workbook, rather than having to click
the pop-up window that asks if I want to enable/disable macros.

Is there a way to do this using Excel automation? How about using API
calls? My intent is that I would like to read the current setting, change
the setting to disable macros, read in the files, then reset the setting to
its original value.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Alter macro security level programmatically

You could use alternative approaches to read the data, for example:

How To Use ADO with Excel Data from Visual Basic or VBA
http://support.microsoft.com/kb/257819

How is Access opening the Excel workbooks? If you use VBA to open a document
with macros in an instance of its parent application, the fact that VBA is
running counts as an approval to run code, so you should not be warned.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dale Fye" wrote in message
...
I have an Access application that is opening a number of Excel spreadsheets
and reading data from them. Each of these spreadsheets has the same
macros,
which I want to disable when I open the workbook, rather than having to
click
the pop-up window that asks if I want to enable/disable macros.

Is there a way to do this using Excel automation? How about using API
calls? My intent is that I would like to read the current setting, change
the setting to disable macros, read in the files, then reset the setting
to
its original value.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Alter macro security level programmatically

Great idea Jon. Had not even considered using ADO to read data from Excel.
I'll take a look.

My problem stems from Access misinterpreting data types when importing or
linking to Excel, so opening an ADO recordset might just do the trick.

Thanks.
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Jon Peltier" wrote:

You could use alternative approaches to read the data, for example:

How To Use ADO with Excel Data from Visual Basic or VBA
http://support.microsoft.com/kb/257819

How is Access opening the Excel workbooks? If you use VBA to open a document
with macros in an instance of its parent application, the fact that VBA is
running counts as an approval to run code, so you should not be warned.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Dale Fye" wrote in message
...
I have an Access application that is opening a number of Excel spreadsheets
and reading data from them. Each of these spreadsheets has the same
macros,
which I want to disable when I open the workbook, rather than having to
click
the pop-up window that asks if I want to enable/disable macros.

Is there a way to do this using Excel automation? How about using API
calls? My intent is that I would like to read the current setting, change
the setting to disable macros, read in the files, then reset the setting
to
its original value.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Alter macro security level programmatically

I get your point, but my code is digitally signed, so it can run at the
higher security levels.

My preference was to Open the workbook, hoping that there was a way within
the GetObject or wbk.Open methods to disable the macros automatically. In
the absense of that, I was looking for any other possible alternatives, Jon's
idea to open an ADO recordset may just work.

Thanks for your feedback.
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Don Guillett" wrote:

Think about it. If you could then what is the use of having security in the
first place?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dale Fye" wrote in message
...
I have an Access application that is opening a number of Excel spreadsheets
and reading data from them. Each of these spreadsheets has the same
macros,
which I want to disable when I open the workbook, rather than having to
click
the pop-up window that asks if I want to enable/disable macros.

Is there a way to do this using Excel automation? How about using API
calls? My intent is that I would like to read the current setting, change
the setting to disable macros, read in the files, then reset the setting
to
its original value.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro-Security level value avi Excel Programming 3 July 12th 07 04:41 PM
set macro security level through VBA bill_morgan Excel Programming 4 August 1st 05 06:29 PM
??Programmatically set security level to medium DG Excel Programming 8 March 1st 04 10:00 PM
Using VBA to change macro security level Tracey[_4_] Excel Programming 4 January 23rd 04 07:20 PM
Macro to change security level Michael Miazga[_2_] Excel Programming 2 July 21st 03 08:39 PM


All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"