Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Fri, 14 Sep 2007 15:34:02 -0700,    group: microsoft.public.word.vba.addins        back       


BUG on Framework??   
hi to all, I have an issue with a feature of an addin.

I did a simple word add-in that catch the "Save" event and the "Print" event.
When the addin catchs these events, it must show a simple MSGBOX ("bye") and 
MSWord doesn't save or print the active document.

For do that, I used a object word and catch the event "documentBeforeSave" 
and "documentBeforePrint" and I see on the MSDN that If I set a Cancel 
variable to TRUE  the active document doesn't saved.

The problem is If I set Cancel variable to TRUE, the document will be saved 
anyway!

What is the problem? there is a bug in the framework, or I'm not using it in 
the right way?

thank you!
date: Fri, 14 Sep 2007 15:34:02 -0700   author:   dev

Re: BUG on Framework??   
Hi dev,
It looks like you got your information from a page like this:
<http://msdn2.microsoft.com/en-us/library/aa263710(office.10).aspx>
Did you follow the link on that page to and create a *class* module?:
<http://msdn2.microsoft.com/en-us/library/aa263743(office.10).aspx>

Anyway, here is more info using Word VBA:
<http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm>


> hi to all, I have an issue with a feature of an addin.
> 
> I did a simple word add-in that catch the "Save" event and the "Print" event.
> When the addin catchs these events, it must show a simple MSGBOX ("bye") and
> MSWord doesn't save or print the active document.
> 
> For do that, I used a object word and catch the event "documentBeforeSave"
> and "documentBeforePrint" and I see on the MSDN that If I set a Cancel
> variable to TRUE  the active document doesn't saved.
> 
> The problem is If I set Cancel variable to TRUE, the document will be saved
> anyway!
> 
> What is the problem? there is a bug in the framework, or I'm not using it in
> the right way?
> 
> thank you!

-- 
Russ

 drsmN0SPAMikleAThotmailD0Tcom.INVALID
date: Sat, 15 Sep 2007 13:55:33 -0400   author:   Russ LID

Re: BUG on Framework??   
Hi Russ! Thank you very much for the help.

I'm studying the links you showing me, but the code that I'm reading in the 
second link, doesn't works:
Dim X As New EventClassModule
Sub Register_Event_Handler()
    Set X.App = Word.Application
End Sub

I'm developing an Word Addin using VB .NET and the "Set" keyword, doesn't 
exists; when I paste that code in the developing enviroment, the "Set" 
keyword disappear, I'm developing a word addin, maybe that code refers to VBA 
language.

Anyway, 
this is the code I've put in the DocumentBeforePrint Sub in my Word Addin:

       Try

                MsgBox("Hello World!")
                Cancel = True
         
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

I set "Cancel" to TRUE becouse I read this:

Cancel-   False when the event occurs. If the event procedure sets this 
argument to True, the document isn't printed when the procedure is finished.

So I think I should see the MSGBOX "HelloWorld" and I can't see the window 
for Print the Document...it's not true! I can see the MSGBOX and I can see 
the window for Print and I can print the active document.

Have you a workaround for my problem?

thank you
date: Sun, 16 Sep 2007 15:50:03 -0700   author:   dev

Re: BUG on Framework??   
Dev,
Sorry, I know nothing about VB .NET coding. I can only offer some info on
VBA code. You might be able to study VBA code to get an idea about code to
use, but it will be up to you to translate that code to VB .NET.
For example, if you start Word and press ALT F11, it will bring up the Word
VBA Editor. Use the help menu and type in the word 'set' to see what it does
in VBA. Then decide what you would use in VB .NET for doing the same thing.
And of course Google knows everything:
<http://www.google.com/search?&q=%22vb%20.net%22+vba>

 We are mostly volunteers in this forum offering info and the forum deals
with word VBA. I suggest you look for a VB .NET forum for more germane
suggestions.

> Hi Russ! Thank you very much for the help.
> 
> I'm studying the links you showing me, but the code that I'm reading in the
> second link, doesn't works:
> Dim X As New EventClassModule
> Sub Register_Event_Handler()
>     Set X.App = Word.Application
> End Sub
> 
> I'm developing an Word Addin using VB .NET and the "Set" keyword, doesn't
> exists; when I paste that code in the developing enviroment, the "Set"
> keyword disappear, I'm developing a word addin, maybe that code refers to VBA
> language.
> 
> Anyway, 
> this is the code I've put in the DocumentBeforePrint Sub in my Word Addin:
> 
>        Try
> 
>                 MsgBox("Hello World!")
>                 Cancel = True
>          
>         Catch ex As Exception
>             MsgBox(ex.ToString)
>         End Try
> 
> I set "Cancel" to TRUE becouse I read this:
> 
> Cancel-   False when the event occurs. If the event procedure sets this
> argument to True, the document isn't printed when the procedure is finished.
> 
> So I think I should see the MSGBOX "HelloWorld" and I can't see the window
> for Print the Document...it's not true! I can see the MSGBOX and I can see
> the window for Print and I can print the active document.
> 
> Have you a workaround for my problem?
> 
> thank you

-- 
Russ

 drsmN0SPAMikleAThotmailD0Tcom.INVALID
date: Mon, 17 Sep 2007 13:44:04 -0400   author:   Russ LID

Re: BUG on Framework??   
OK Russ, thank u very much anyway.

bye
date: Mon, 17 Sep 2007 16:54:01 -0700   author:   dev

Re: BUG on Framework??   
Hi dev,

Just wondering if you got this to work?  I've just started writing a Word 
Add-in in VB.Net and have got this to work if you still need a hand.
date: Tue, 27 Nov 2007 17:49:00 -0800   author:   Daryl

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us