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.

BUG on Framework??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dev - 14 Sep 2007 23:34 GMT
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 - 15 Sep 2007 18:55 GMT
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.
>
[quoted text clipped - 13 lines]
>
> thank you!

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

dev - 16 Sep 2007 23:50 GMT
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 - 17 Sep 2007 18:44 GMT
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.
>
[quoted text clipped - 34 lines]
>
> thank you

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

dev - 18 Sep 2007 00:54 GMT
OK Russ, thank u very much anyway.

bye
Daryl - 28 Nov 2007 01:49 GMT
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.
 
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.