ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Macros when opening workbook (https://www.excelbanter.com/excel-programming/307404-disable-macros-when-opening-workbook.html)

Rob[_21_]

Disable Macros when opening workbook
 
How do i disable macros when opening a workbook in code?

I have a workbook that creates a new menu when it opens
and destroys the menu when it closes. One of the choices
in that menu is to open an older version of that same
workbook and import its data and then close that workbook.
When it closes, it destroys the wrong menu. How do i solve
this problem?

One way would be to disable macros on the workbook that is
opened in code. Another would be to temporarily set macro
security to high. Any other ideas?

Tom Ogilvy

Disable Macros when opening workbook
 
You can disable events

Application.EnableEvents = False
workbooks.Open Filename:="myworkbook.xls"
Application.EnableEvents = True

--
regards,
Tom Ogilvy

"Rob" wrote in message
...
How do i disable macros when opening a workbook in code?

I have a workbook that creates a new menu when it opens
and destroys the menu when it closes. One of the choices
in that menu is to open an older version of that same
workbook and import its data and then close that workbook.
When it closes, it destroys the wrong menu. How do i solve
this problem?

One way would be to disable macros on the workbook that is
opened in code. Another would be to temporarily set macro
security to high. Any other ideas?




JD

Disable Macros when opening workbook
 
How can I d o this "temporarily set macro security to high" in VBA ??

regards , Jeroen

"Tom Ogilvy" schreef in bericht
...
You can disable events

Application.EnableEvents = False
workbooks.Open Filename:="myworkbook.xls"
Application.EnableEvents = True

--
regards,
Tom Ogilvy

"Rob" wrote in message
...
How do i disable macros when opening a workbook in code?

I have a workbook that creates a new menu when it opens
and destroys the menu when it closes. One of the choices
in that menu is to open an older version of that same
workbook and import its data and then close that workbook.
When it closes, it destroys the wrong menu. How do i solve
this problem?

One way would be to disable macros on the workbook that is
opened in code. Another would be to temporarily set macro
security to high. Any other ideas?






Dave Peterson[_3_]

Disable Macros when opening workbook
 
If you use the code Tom suggested, you won't have to.

And turn off events when you close the workbook, too.



JD wrote:

How can I d o this "temporarily set macro security to high" in VBA ??

regards , Jeroen

"Tom Ogilvy" schreef in bericht
...
You can disable events

Application.EnableEvents = False
workbooks.Open Filename:="myworkbook.xls"
Application.EnableEvents = True

--
regards,
Tom Ogilvy

"Rob" wrote in message
...
How do i disable macros when opening a workbook in code?

I have a workbook that creates a new menu when it opens
and destroys the menu when it closes. One of the choices
in that menu is to open an older version of that same
workbook and import its data and then close that workbook.
When it closes, it destroys the wrong menu. How do i solve
this problem?

One way would be to disable macros on the workbook that is
opened in code. Another would be to temporarily set macro
security to high. Any other ideas?




--

Dave Peterson


ScottDK

Disable Macros when opening workbook
 

I am looking for an answer to the original question.

I have a worksheet containing a list of hundreds of users' workbooks on
a number of network servers. I want to identify which contain VBA code
and which don't. Later it will be my job to test that they run in our
new company environment (Office 97 - Office XP; Windows 2000 -
Windows XP). This is only the first of such lists, and will be
looking at potentially thousands of workbooks over the next couple of
months.

Rather than open them all up manually, I wrote a simple procedure to
scan through the list of paths, open each workbook, sum up the
CountOfLines in each CodeModule, then close the workbook. I will run
this overnight, and come back tomorrow and focus on the workbooks that
contain vba code.

I do not want to execute macros when I open each workbook.
OK... Solution : turn off events as suggested above

This worked fine, until my application started opening workbooks with
references to some obscure fiancial libraries that some users have
installed that I don't have. The Workbook_Open doesn't run, but Excel
still tries to COMPILE the code. The compilation fails, shows me the
errant line of code in the user's workbook. Neither disable events nor
disable alerts stops this. I really want to disable macros completely
when I open up each workbook. But I still want to be able to count how
many lines of code....


--
ScottDK
------------------------------------------------------------------------
ScottDK's Profile: http://www.excelforum.com/member.php...o&userid=16393
View this thread: http://www.excelforum.com/showthread...hreadid=248696


keepITcool

Disable Macros when opening workbook
 
use
Application.AutomationSecurity = msoAutomationSecurityForceDisable





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


ScottDK wrote :


I am looking for an answer to the original question.

I have a worksheet containing a list of hundreds of users' workbooks
on a number of network servers. I want to identify which contain VBA
code and which don't. Later it will be my job to test that they run
in our new company environment (Office 97 - Office XP; Windows 2000
- Windows XP). This is only the first of such lists, and will be
looking at potentially thousands of workbooks over the next couple of
months.

Rather than open them all up manually, I wrote a simple procedure to
scan through the list of paths, open each workbook, sum up the
CountOfLines in each CodeModule, then close the workbook. I will run
this overnight, and come back tomorrow and focus on the workbooks that
contain vba code.

I do not want to execute macros when I open each workbook.
OK... Solution : turn off events as suggested above

This worked fine, until my application started opening workbooks with
references to some obscure fiancial libraries that some users have
installed that I don't have. The Workbook_Open doesn't run, but Excel
still tries to COMPILE the code. The compilation fails, shows me the
errant line of code in the user's workbook. Neither disable events
nor disable alerts stops this. I really want to disable macros
completely when I open up each workbook. But I still want to be able
to count how many lines of code....


NickHK

Disable Macros when opening workbook
 
keepITcool.
Only for Office XP and up ?
As my Office2K does not support that.

NickHK

"keepITcool" wrote in message
ft.com...
use
Application.AutomationSecurity = msoAutomationSecurityForceDisable





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


ScottDK wrote :


I am looking for an answer to the original question.

I have a worksheet containing a list of hundreds of users' workbooks
on a number of network servers. I want to identify which contain VBA
code and which don't. Later it will be my job to test that they run
in our new company environment (Office 97 - Office XP; Windows 2000
- Windows XP). This is only the first of such lists, and will be
looking at potentially thousands of workbooks over the next couple of
months.

Rather than open them all up manually, I wrote a simple procedure to
scan through the list of paths, open each workbook, sum up the
CountOfLines in each CodeModule, then close the workbook. I will run
this overnight, and come back tomorrow and focus on the workbooks that
contain vba code.

I do not want to execute macros when I open each workbook.
OK... Solution : turn off events as suggested above

This worked fine, until my application started opening workbooks with
references to some obscure fiancial libraries that some users have
installed that I don't have. The Workbook_Open doesn't run, but Excel
still tries to COMPILE the code. The compilation fails, shows me the
errant line of code in the user's workbook. Neither disable events
nor disable alerts stops this. I really want to disable macros
completely when I open up each workbook. But I still want to be able
to count how many lines of code....




keepITcool

Disable Macros when opening workbook
 
yep. that sounds like a fair assumption.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


NickHK wrote :

keepITcool.
Only for Office XP and up ?
As my Office2K does not support that.

NickHK

"keepITcool" wrote in message
ft.com...
use
Application.AutomationSecurity = msoAutomationSecurityForceDisable



All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com