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 / October 2006

Tip: Looking for answers? Try searching our database.

MVP.Org pseudoautomacros: How to...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JeffP@Laptop - 25 Oct 2006 19:25 GMT
I'm having a problem implementing this programming...

ref: http://word.mvps.org/faqs/macrosvba/pseudoautomacros.htm

Word2000

I have added to my existing "ADOTemplate" module the code

Option Explicit

Dim oAppClass As New ThisApplication
Public oldNoOfOpenDocs As Long
Public FirstNewDoc As Boolean

Public Sub AutoExec()
   Set oAppClass.oApp = Word.Application
   oldNoOfOpenDocs = 0
   FirstNewDoc = True
End Sub

I added a class module "ThisApplication" with....

Option Explicit

Public WithEvents oApp As Word.Application
---------------------------------------------------------------------
Private Sub oApp_DocumentChange()

On Error GoTo ExitCode

Dim newNoOfOpenDocs As Long
.......ending....
   Call DocChangedFocus
End If

Exit Sub

ExitCode:

End Sub

Q1: Should the oApp_DocumentChange() be in my "ADOTemplate" module or the
ThisApp class module ?

Q2: Should the oApp_DocumentOpen() be in the "ThisDocument" class module?

Q2b: How does the Doc in "oApp_DocumentOpen(ByVal Doc as Document)" get
passed in, looking at the code it appears that it's implied?

TIA

JeffP...
Jezebel - 25 Oct 2006 21:24 GMT
> I'm having a problem implementing this programming...
>
[quoted text clipped - 48 lines]
>
> JeffP...
JeffP@Work - 25 Oct 2006 21:37 GMT
I've got the process working... BUT

I'm not finding a way to envoke the methods when printing (right-click
|Print)

JeffP.....

>> I'm having a problem implementing this programming...
>>
[quoted text clipped - 48 lines]
>>
>> JeffP...
Jezebel - 25 Oct 2006 22:54 GMT
Which methods? The code you've created traps *events*.

> I've got the process working... BUT
>
[quoted text clipped - 56 lines]
>>>
>>> JeffP...
JeffP@Work - 26 Oct 2006 00:11 GMT
Ok, it works for any user that will open and prehaps edit the doc which is
about 1 out of 10 times.

The other times the doc is printed similar to the right-click.

I was hoping that there was an application event for the printing.

I even tried adding some of this same code for events in the template and
removed it from the addin, but although it basically works, the right-click
print still does not with the added pain of being prompted for the macro
security.

My only choice seems to be to set the security low :-(

... and re-place my AutoExec()

The whole problem arrose because I didn't check my security settings which
were low, and when I went to install my template and the addin which has
it's own install module, and addin checking w/in the template its self.

It was working perfectly w/low security, using AutoExec()

What's a novice VBA programmer to do... ?

JeffP.....

> Which methods? The code you've created traps *events*.
>
[quoted text clipped - 58 lines]
>>>>
>>>> JeffP...
Jonathan West - 26 Oct 2006 00:10 GMT
> I've got the process working... BUT
>
> I'm not finding a way to envoke the methods when printing (right-click
> |Print)

Use the DocumentBeforePrint event. look it up in the VBA help.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Jezebel - 25 Oct 2006 21:35 GMT
> I'm having a problem implementing this programming...
>
[quoted text clipped - 36 lines]
>
> End Sub

> Q1: Should the oApp_DocumentChange() be in my "ADOTemplate" module or the
> ThisApp class module ?

Event functions have to be in the module in which the withevents variable
(oApp in this case) is declared. And you can use withevents only in a class
module.

> Q2: Should the oApp_DocumentOpen() be in the "ThisDocument" class module?

As for question 1 -- it has to be where you declared oApp. And it has to be
declared as

oApp_DocumentOpen(ByVal Doc as Document).

Once you've added the withevents declaration, you can select the variable
from the drop down at the top-left of the code window where you normally see
'(general)' or 'Class', then select the function from the drop-down on the
right. The arguments are supplied automatically.
 
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.