Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Application Events / App_WorkbookOpen

Hello all,

What I´m trying to do:
Everytime I open an existing Workbook I want the PrintSettings for all
the sheets to be Draft. I cannot do this in the printersettings
directly because of restrictions.

What I came up with so far:
In my Personal.xls I did the following:

- I created a new class module: Class1
- I wrote in Class1:
Public WithEvents App As Application
- I wrote in Class1:
Private Sub App_WorkbookOpen(ByVal WB As Excel.Workbook)
Dim page As Worksheet
For Each page In Worksheets
page.PageSetup.Draft = True
Next page
End Sub

This doesn´t do the trick... can anyone tell me why not?

thanks
Fries
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Application Events / App_WorkbookOpen

Fries,

You have to enable application events. I do this by adding this line in my
Workbook_Open event (for Personal.xls)


Set AppClass.App = Application

assuming the class is named AppClass. Have you done this?

That workbook event can also be run from the VBE by clicking in the event
code and run.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Fries" wrote in message
om...
Hello all,

What I´m trying to do:
Everytime I open an existing Workbook I want the PrintSettings for all
the sheets to be Draft. I cannot do this in the printersettings
directly because of restrictions.

What I came up with so far:
In my Personal.xls I did the following:

- I created a new class module: Class1
- I wrote in Class1:
Public WithEvents App As Application
- I wrote in Class1:
Private Sub App_WorkbookOpen(ByVal WB As Excel.Workbook)
Dim page As Worksheet
For Each page In Worksheets
page.PageSetup.Draft = True
Next page
End Sub

This doesn´t do the trick... can anyone tell me why not?

thanks
Fries



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Application Events / App_WorkbookOpen

You need to create an instance of Class1 in a normal code module,
and then set the App variable to the Application. E.g.,

Dim AppClass As Class1
Set AppClass.App = Application


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Fries" wrote in message
om...
Hello all,

What I´m trying to do:
Everytime I open an existing Workbook I want the PrintSettings
for all
the sheets to be Draft. I cannot do this in the printersettings
directly because of restrictions.

What I came up with so far:
In my Personal.xls I did the following:

- I created a new class module: Class1
- I wrote in Class1:
Public WithEvents App As Application
- I wrote in Class1:
Private Sub App_WorkbookOpen(ByVal WB As Excel.Workbook)
Dim page As Worksheet
For Each page In Worksheets
page.PageSetup.Draft = True
Next page
End Sub

This doesn´t do the trick... can anyone tell me why not?

thanks
Fries



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Application Events / App_WorkbookOpen

Dim AppClass As Class1
Set AppClass.App = Application


should be
Dim AppClass As Class1
Set AppClass = New Class1
Set AppClass.App = Application


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
You need to create an instance of Class1 in a normal code
module, and then set the App variable to the Application. E.g.,

Dim AppClass As Class1
Set AppClass.App = Application


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Fries" wrote in message
om...
Hello all,

What I´m trying to do:
Everytime I open an existing Workbook I want the PrintSettings
for all
the sheets to be Draft. I cannot do this in the
printersettings
directly because of restrictions.

What I came up with so far:
In my Personal.xls I did the following:

- I created a new class module: Class1
- I wrote in Class1:
Public WithEvents App As Application
- I wrote in Class1:
Private Sub App_WorkbookOpen(ByVal WB As Excel.Workbook)
Dim page As Worksheet
For Each page In Worksheets
page.PageSetup.Draft = True
Next page
End Sub

This doesn´t do the trick... can anyone tell me why not?

thanks
Fries





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Application Events / App_WorkbookOpen

missed the line
Dim AppClass as clsAppEvents

my class is called clsAppEvents

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...
Fries,

You have to enable application events. I do this by adding this line in my
Workbook_Open event (for Personal.xls)


Set AppClass.App = Application

assuming the class is named AppClass. Have you done this?

That workbook event can also be run from the VBE by clicking in the event
code and run.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Fries" wrote in message
om...
Hello all,

What I´m trying to do:
Everytime I open an existing Workbook I want the PrintSettings for all
the sheets to be Draft. I cannot do this in the printersettings
directly because of restrictions.

What I came up with so far:
In my Personal.xls I did the following:

- I created a new class module: Class1
- I wrote in Class1:
Public WithEvents App As Application
- I wrote in Class1:
Private Sub App_WorkbookOpen(ByVal WB As Excel.Workbook)
Dim page As Worksheet
For Each page In Worksheets
page.PageSetup.Draft = True
Next page
End Sub

This doesn´t do the trick... can anyone tell me why not?

thanks
Fries







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application Events / App_WorkbookOpen

Hey Chip and Bob,

thanks for the help, got it working now.

Fries

In article ,
says...
Dim AppClass As Class1
Set AppClass.App = Application


should be
Dim AppClass As Class1
Set AppClass = New Class1
Set AppClass.App = Application



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
Application Level Events Question nickg420[_4_] Excel Programming 3 July 16th 04 05:02 PM
Application level events no longer execute R Avery Excel Programming 1 June 4th 04 01:21 AM
Just having App_WorkbookOpen crashes Excel Aaron Fude Excel Programming 4 May 13th 04 08:33 PM
Using Application Events Thomas Herr Excel Programming 2 April 5th 04 09:24 PM
How-To - Forwarding Excel 2000 events to .Net application Joel Foner Excel Programming 0 January 28th 04 11:34 PM


All times are GMT +1. The time now is 02:26 AM.

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"