Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Using Events with the Application Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LEU - 17 Nov 2007 18:18 GMT
I was looking in the help and it said the following:

Before the procedure will run, you must connect the declared object in the
class module (wdApp in my example) with the Application object. You can do
this with the following code from any module.

Dim X As New EventClassModule
Sub Register_Event_Handler()
   Set X.wdApp = Word.Application
End Sub

When I debug I get the following error: User-defined type not defined
and it points tothe following: Dim X As New EventClassModule

What am I doing wrong.
Helmut Weber - 17 Nov 2007 19:39 GMT
see:

http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
Jay Freedman - 17 Nov 2007 20:05 GMT
The answer is buried in the text of the help topic, under the heading
"Declare the Object Variable":

"For example, assume that a new class module is created and called
EventClassModule."

If you created a new class module, by default it is named Class1, and
you have to either rename it (in the Properties pane) to
EventClassModule, or else change the module code to

 Dim X As New Class1

to match the default name.

Bill Coan was more explicit about this step in his article at
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm.

>I was looking in the help and it said the following:
>
[quoted text clipped - 11 lines]
>
>What am I doing wrong.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
LEU - 22 Nov 2007 02:19 GMT
Thanks all 3 of you for the information. I now know how this works. I made
the changes and it almost works . I am having problem with the autoexec macro
to get it to work, but I'll post it as a new question.

LEU

> The answer is buried in the text of the help topic, under the heading
> "Declare the Object Variable":
[quoted text clipped - 34 lines]
> Microsoft Word MVP        FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Dave D-C - 19 Nov 2007 03:27 GMT
Leu,
And the help says
"For example, assume that a new class module is created and called
EventClassModule. "
So "EventClassModule" is the class module name,
not a reserved word.

D-C Dave

>I was looking in the help and it said the following:
>
[quoted text clipped - 11 lines]
>
>What am I doing wrong.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.