Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Prevent the Macros to be opened in 2nd xls. Sheet

Gavin,

Surround the open statement of the book being opened with statements to turn
off events:

Application.EnableEvents = False
ChDir "M:\QUALITY\E-TALK REPORTS"
Workbooks.Open Filename:="M:\QUALITY\E-TALK REPORTS\Main E-Talk Query.xls"
Application.EnableEvents = True

HTH,
Bernie
MS Excel MVP

"Gavin Taylor" wrote in message
...
Hi,
I have a workbook that runs a piece of code to refreshes query tables from
other .xls sheets. However on some terminals in the department this

invokes
the coerce .xls sheet to open. So I decided to include this in the code

for
consistence sake.
The file that it opens has macros that should be disabled if the file is

to
run in this manner.
I can't seem to find the code to prevent the Macros to be opened in the
secondary xls. Sheet.


Private Sub Workbook_Open()

ChDir "M:\QUALITY\E-TALK REPORTS"
Workbooks.Open Filename:="M:\QUALITY\E-TALK REPORTS\Main E-Talk Query.xls"

Windows("All Call Center Performance.xls").Activate
Sheet3.Select


Application.AddIns(2).Installed = True
Application.AddIns(3).Installed = True
Application.AddIns(7).Installed = True
Application.AddIns(9).Installed = True
Application.AddIns(10).Installed = True

Dim ws As Worksheet
Dim qt As QueryTable
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
Next ws

For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws

Windows("Main E-Talk Query.xls").Activate
ActiveWindow.Close
Windows("All Call Center Performance.xls").Activate
Sheet3.Select
Range("A1").Select

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prevent the Macros to be opened in 2nd xls. Sheet

Thanks Worked fine.

"Bernie Deitrick" wrote:

Gavin,

Surround the open statement of the book being opened with statements to turn
off events:

Application.EnableEvents = False
ChDir "M:\QUALITY\E-TALK REPORTS"
Workbooks.Open Filename:="M:\QUALITY\E-TALK REPORTS\Main E-Talk Query.xls"
Application.EnableEvents = True

HTH,
Bernie
MS Excel MVP

"Gavin Taylor" wrote in message
...
Hi,
I have a workbook that runs a piece of code to refreshes query tables from
other .xls sheets. However on some terminals in the department this

invokes
the coerce .xls sheet to open. So I decided to include this in the code

for
consistence sake.
The file that it opens has macros that should be disabled if the file is

to
run in this manner.
I can't seem to find the code to prevent the Macros to be opened in the
secondary xls. Sheet.


Private Sub Workbook_Open()

ChDir "M:\QUALITY\E-TALK REPORTS"
Workbooks.Open Filename:="M:\QUALITY\E-TALK REPORTS\Main E-Talk Query.xls"

Windows("All Call Center Performance.xls").Activate
Sheet3.Select


Application.AddIns(2).Installed = True
Application.AddIns(3).Installed = True
Application.AddIns(7).Installed = True
Application.AddIns(9).Installed = True
Application.AddIns(10).Installed = True

Dim ws As Worksheet
Dim qt As QueryTable
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
Next ws

For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws

Windows("Main E-Talk Query.xls").Activate
ActiveWindow.Close
Windows("All Call Center Performance.xls").Activate
Sheet3.Select
Range("A1").Select

End Sub




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
How do I prevent users from changing macros? linto Excel Discussion (Misc queries) 1 January 6th 10 01:45 PM
password protect a spreadsheet to prevent it from being opened. spongebobvan Excel Worksheet Functions 2 November 23rd 04 08:12 PM
Workbook opened with macros disabled Alan.Hutchins Excel Programming 1 July 28th 04 09:44 AM
Prevent users from running macros Alan Hutchins Excel Programming 7 June 2nd 04 05:12 PM
Prevent user from disabling macros Michael Monteiro Excel Programming 0 August 21st 03 04:28 AM


All times are GMT +1. The time now is 08:17 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"