LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 772
Default Application level event help

Hi all, just recently got into application level event programming and need a
little help. First, using Chip's site I worked out the following code that
throws an extra validation if printing more than x sheets, works great. Now i
am trying to capture sheet change events and get an 'Object Required' error.
Working code:
This workbook-
Private XLApp As clsExcelEvents

Private Sub Workbook_Open()
Set XLApp = New clsExcelEvents
End Sub

clsExcelEvents class module-
Private WithEvents App As Application


Private Sub Class_Initialize()
Set App = Application

End Sub

Private Sub App_WorkbookBeforePrint(ByVal wb As Workbook, Cancel As Boolean)
Dim strPrint As String
Dim pageCount As Integer

pageCount = 10

If Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") = pageCount Then

strPrint = MsgBox("Are you sure you want to print this? It is " _
& Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") & " Sheets", vbYesNo)

If strPrint = vbNo Then
Cancel = True
MsgBox "Print job hs been cancelled", vbExclamation, "Cancel"
End If

End If
End Sub

Now I have tried several ways but they all fail, here is the latest, keep
workbook_open the same:
clsExcelEvents class module-
Private WithEvents xlWs As Worksheet
Private WithEvents App As Application


Private Sub Class_Initialize()
Set App = Application
Set xlWs = Worksheet
End Sub
Private Sub xlWs_Activate()
Call test
End Sub

standard module-
Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer

Const VK_CONTROL As Integer = &H11 'Ctrl

Sub test()
If GetKeyState(VK_CONTROL) < 0 Then Ctrl = True Else Ctrl = False
If Ctrl = True Then
MsgBox "pressed"
Else
MsgBox "Not"
End If
End Sub


TIA


--
-John
Please rate when your question is answered to help us and others know what
is helpful.
 
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
20 level nested If Hi_no_Tori Excel Discussion (Misc queries) 5 October 11th 07 08:24 AM
2-level subtotals? dlw Excel Discussion (Misc queries) 2 August 17th 07 02:06 AM
Turn off Reviewing options at the application level Tracey Excel Discussion (Misc queries) 1 August 6th 05 12:43 AM
Sum to Defined level Nate Walsh Excel Discussion (Misc queries) 2 March 14th 05 01:54 AM
Level of protection gerryR Excel Discussion (Misc queries) 1 December 7th 04 04:07 PM


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