473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

event sinking with Word question

I've been looking at the event sinking example in Litwin et. al. "Access 97
Developer's Handbook" and I am able to event sink the 2 events listed -
those being the "_quit" and "_documentchange" events described and coded for
in the examples mdb file..

However - some other important events I cannot get to work - some are:

DocumentBeforeClose
DocumentBeforePrint
DocumentBeforeSave
DocumentOpen
etc............

The error I get is: "procedure declaration does not match description of
event or procedure having the same name"
All of these other events have word object types (eg 'document', 'section')
passed as arguements. Is it just a coincidence that the only 2 events coded
for do not have any arguements or is there some additional work necessary to
tap into these events that was not discussed in the text?

Thanks
Nov 13 '05 #1
4 2380

Do you have a reference to Microsoft Word?

--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:Ov******************@twister.rdc-kc.rr.com...
I've been looking at the event sinking example in Litwin et. al. "Access 97 Developer's Handbook" and I am able to event sink the 2 events listed -
those being the "_quit" and "_documentchange" events described and coded for in the examples mdb file..

However - some other important events I cannot get to work - some are:

DocumentBeforeClose
DocumentBeforePrint
DocumentBeforeSave
DocumentOpen
etc............

The error I get is: "procedure declaration does not match description of
event or procedure having the same name"
All of these other events have word object types (eg 'document', 'section') passed as arguements. Is it just a coincidence that the only 2 events coded for do not have any arguements or is there some additional work necessary to tap into these events that was not discussed in the text?

Thanks

Nov 13 '05 #2
yes - wouldn't the example event sinks ("_quit" and "_documentchange")
fail if this was not so?

thanks )
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:R4********************@karoo.co.uk...

Do you have a reference to Microsoft Word?

--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:Ov******************@twister.rdc-kc.rr.com...
I've been looking at the event sinking example in Litwin et. al. "Access 97
Developer's Handbook" and I am able to event sink the 2 events listed -
those being the "_quit" and "_documentchange" events described and coded

for
in the examples mdb file..

However - some other important events I cannot get to work - some are:

DocumentBeforeClose
DocumentBeforePrint
DocumentBeforeSave
DocumentOpen
etc............

The error I get is: "procedure declaration does not match description of event or procedure having the same name"
All of these other events have word object types (eg 'document',

'section')
passed as arguements. Is it just a coincidence that the only 2 events

coded
for do not have any arguements or is there some additional work

necessary to
tap into these events that was not discussed in the text?

Thanks


Nov 13 '05 #3

I would expect so but not having the book you reference I'm not exactly sure
what Ken et al are doing there.

So in answer to your original questions then:-
I don't see why it would be a coincidence.
No there is no other work required.

To expand
----------------
All you should need to do is
1) establish a reference to Microsoft Word
2) create a class module and declare a variable of type Word.Application
with the Withevents keyword
3) drop the lefthand combo at the top of the window and find your
Word.Application variable in there
4) then pick off the events you want to sink from the right hand combo.

The declarations should then be correct.

Check that argument references to things like Document are disambiguated in
the procedure declaration (e.g. var as Word.Document not var as Document)
and you should be away.

Sample:
------------
Option Explicit

Private WithEvents waVar As Word.Application
' ***************************************
'

Private Sub waVar_DocumentBeforeClose( _
ByVal Doc As Word.Document, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentBeforePrint( _
ByVal Doc As Word.Document, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentBeforeSave( _
ByVal Doc As Word.Document, _
SaveAsUI As Boolean, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentChange()
'
End Sub

Private Sub waVar_DocumentOpen( _
ByVal Doc As Word.Document _
)
'
End Sub

Private Sub waVar_Quit()
'
End Sub
--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:b2******************@twister.rdc-kc.rr.com...
yes - wouldn't the example event sinks ("_quit" and "_documentchange")
fail if this was not so?

thanks )
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:R4********************@karoo.co.uk...

Do you have a reference to Microsoft Word?

--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:Ov******************@twister.rdc-kc.rr.com...
I've been looking at the event sinking example in Litwin et. al. "Access
97
Developer's Handbook" and I am able to event sink the 2 events
listed - those being the "_quit" and "_documentchange" events described and coded
for
in the examples mdb file..

However - some other important events I cannot get to work - some

are:
DocumentBeforeClose
DocumentBeforePrint
DocumentBeforeSave
DocumentOpen
etc............

The error I get is: "procedure declaration does not match description

of event or procedure having the same name"
All of these other events have word object types (eg 'document',

'section')
passed as arguements. Is it just a coincidence that the only 2 events

coded
for do not have any arguements or is there some additional work

necessary
to
tap into these events that was not discussed in the text?

Thanks



Nov 13 '05 #4
Thanks - it was my neglect of the 'byval' aruegment that was causing all the
fuss. Looking at you example code resolved this.

))
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:0m********************@karoo.co.uk...

I would expect so but not having the book you reference I'm not exactly sure what Ken et al are doing there.

So in answer to your original questions then:-
I don't see why it would be a coincidence.
No there is no other work required.

To expand
----------------
All you should need to do is
1) establish a reference to Microsoft Word
2) create a class module and declare a variable of type Word.Application with the Withevents keyword
3) drop the lefthand combo at the top of the window and find your
Word.Application variable in there
4) then pick off the events you want to sink from the right hand combo.
The declarations should then be correct.

Check that argument references to things like Document are disambiguated in the procedure declaration (e.g. var as Word.Document not var as Document)
and you should be away.

Sample:
------------
Option Explicit

Private WithEvents waVar As Word.Application
' ***************************************
'

Private Sub waVar_DocumentBeforeClose( _
ByVal Doc As Word.Document, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentBeforePrint( _
ByVal Doc As Word.Document, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentBeforeSave( _
ByVal Doc As Word.Document, _
SaveAsUI As Boolean, _
Cancel As Boolean _
)
'
End Sub

Private Sub waVar_DocumentChange()
'
End Sub

Private Sub waVar_DocumentOpen( _
ByVal Doc As Word.Document _
)
'
End Sub

Private Sub waVar_Quit()
'
End Sub
--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:b2******************@twister.rdc-kc.rr.com...
yes - wouldn't the example event sinks ("_quit" and "_documentchange")
fail if this was not so?

thanks )
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:R4********************@karoo.co.uk...

Do you have a reference to Microsoft Word?

--
Terry Kreft
MVP Microsoft Access
"astro" <as*********@mn.rr.com> wrote in message
news:Ov******************@twister.rdc-kc.rr.com...
> I've been looking at the event sinking example in Litwin et. al. "Access 97
> Developer's Handbook" and I am able to event sink the 2 events listed - > those being the "_quit" and "_documentchange" events described and coded for
> in the examples mdb file..
>
> However - some other important events I cannot get to work - some are: >
> DocumentBeforeClose
> DocumentBeforePrint
> DocumentBeforeSave
> DocumentOpen
> etc............
>
> The error I get is: "procedure declaration does not match description
of
> event or procedure having the same name"
>
>
> All of these other events have word object types (eg 'document',
'section')
> passed as arguements. Is it just a coincidence that the only 2

events coded
> for do not have any arguements or is there some additional work

necessary
to
> tap into these events that was not discussed in the text?
>
> Thanks
>
>



Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
1
by: AP | last post by:
Hi, I'm trying to use c# to pop up a dialog box when a user attempts to close word to prompt them if they want to exit or cancel (obviously other stuff needs to happen based on their selection...
2
by: learn_remoting | last post by:
Hello, I am trying to understand the details of .net remoting. There are so many different kinds of sinks .... which have left me totally confused. TerminatorSinks, ContextSinks, MessageSinks,...
0
by: Graham R Seach | last post by:
Hi guys, A colleague is trying to instantiate a specific Access 2000 form in C#, and when the user closes the form, he wants to sink the form's Close event. He's a novice at C#, and can't seem...
3
by: WStoreyII | last post by:
I know that by using the event key word you cant create and event and then a delegate to hanld that event my question is how does one tell the computer what defines the event say for example...
0
by: Vasiliy | last post by:
Hi all! I'm developing an application to manage word templates and documents. Documents are stored in database, so when user wants to edit a document i make a local copy of this document and then...
12
by: 2803stan | last post by:
I have a successful app which is used in a variety of client/server situations. (DB2 8.x.) I need to update it to have XML capability to interface with several other external programs. ...
0
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts...
4
by: tshad | last post by:
I am just getting started with events and had a couple of questions on why they do what they do. If you have a textbox and you want to handle an event you can just do: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.