Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How mk code applicable to any active workbook?

I created a macro that will create footers for the active
wkbk, but does anyone know how to get a given macro to
run on any workbook that is open and not just the active
workbook? In other words I want this macro to be
executed on any workbooks that happen to be active at the
time. (Rather than be executable soley on one specific
macro.)

Thanks,
Chet



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How mk code applicable to any active workbook?

Hi Chet,

I think you are referring to application events. You can set it up so that
all workbooks print a value. To do this you need application events, and put
this is a separate workbook, such as Personal.xls, and then any workbook
will adopt these properties. No need to code each workbook with it.

This is what you need to do.

Firstly, all of this code goes in the the designated workbook.

'========================================
Insert a class module, rename it to 'clsAppEvents', with this code

Option Explicit

Public WithEvents App As Application

Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
With Wb.ActiveSheet
.PageSetup.LeftFooter = "some text"
End With
End Sub

'========================================
In ThisWorkbook code module, add this event code

Dim AppClass As New clsAppEvents

Private Sub Workbook_Open()

Set AppClass.App = Application

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Chet Shannon" wrote in message
...
I created a macro that will create footers for the active
wkbk, but does anyone know how to get a given macro to
run on any workbook that is open and not just the active
workbook? In other words I want this macro to be
executed on any workbooks that happen to be active at the
time. (Rather than be executable soley on one specific
macro.)

Thanks,
Chet





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How mk code applicable to any active workbook?

Thanks Bob... ! I will give it a try...
Chet
-----Original Message-----
Hi Chet,

I think you are referring to application events. You

can set it up so that
all workbooks print a value. To do this you need

application events, and put
this is a separate workbook, such as Personal.xls, and

then any workbook
will adopt these properties. No need to code each

workbook with it.

This is what you need to do.

Firstly, all of this code goes in the the designated

workbook.

'========================================
Insert a class module, rename it to 'clsAppEvents', with

this code

Option Explicit

Public WithEvents App As Application

Private Sub App_WorkbookBeforePrint(ByVal Wb As

Workbook, Cancel As Boolean)
With Wb.ActiveSheet
.PageSetup.LeftFooter = "some text"
End With
End Sub

'========================================
In ThisWorkbook code module, add this event code

Dim AppClass As New clsAppEvents

Private Sub Workbook_Open()

Set AppClass.App = Application

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Chet Shannon"

wrote in message
...
I created a macro that will create footers for the

active
wkbk, but does anyone know how to get a given macro to
run on any workbook that is open and not just the

active
workbook? In other words I want this macro to be
executed on any workbooks that happen to be active at

the
time. (Rather than be executable soley on one specific
macro.)

Thanks,
Chet





.

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
What is the code for the active worksheet? Dr Dan[_2_] Excel Discussion (Misc queries) 12 February 23rd 07 03:12 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
How do I make an open workbook the active workbook Don Guillett[_4_] Excel Programming 0 December 30th 03 04:28 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM
Code to print most (not all) pages within active workbook AlanN Excel Programming 7 August 8th 03 05:26 PM


All times are GMT +1. The time now is 10:30 PM.

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

About Us

"It's about Microsoft Excel"