Reputation: 99
how can i disable "print" & "print preview" in Microsoft Word with WordApplication (delphi7)?
Upvotes: 1
Views: 918
Reputation: 1093
One way is to set up a COM Event Sink and listen for IApplicationEvents2 or IApplicationEvents3. You can respond to DocumentBeforePrint() and set the cancel flag. This should disable printing, but don't know about Print Preview. I have had a bit of a search but haven't found a good reference for doing this from Delphi (but I'm certain it can be done...)
If you were working in VBA, you could also create FilePrint and FilePrintPreview macros to override the default behaviours and disable print functions.
Further Info
Look at the sample \Program Files\Borland\Delphi7\Demos\ActiveX\OleAuto\Word8\word8auto.dpr
This only traps the IApplicationEvents. You will need to extend this to support IApplicationEvents2.
From looking at the code, the required changes are:
Upvotes: 1