Capturing the Print command via a macro

B

Bill Bowes

I have a word document, with a macro that recognises the fact that the user
is going to print, (FilePrint command) and brings up a message box telling
the user that "Printed copies are uncontrolled", and then places a watermark
(in the header footer) to put in "printed on...." and puts in the system date.

All works fine in MS Word, but not all users have Word, some only have
Internet Explorer V6. The macro works fine if the user uses Ctrl P to print,
but if they go to File|Print from the menu, it does not work.

Help!!! any ideas how I can capture the IE File|Print function???
 
J

Jonathan West

Bill Bowes said:
I have a word document, with a macro that recognises the fact that the user
is going to print, (FilePrint command) and brings up a message box
telling
the user that "Printed copies are uncontrolled", and then places a
watermark
(in the header footer) to put in "printed on...." and puts in the system
date.

All works fine in MS Word, but not all users have Word, some only have
Internet Explorer V6. The macro works fine if the user uses Ctrl P to
print,
but if they go to File|Print from the menu, it does not work.

Help!!! any ideas how I can capture the IE File|Print function???

You can't. Any code in the Word document will not run if it is open in an IE
window.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
B

Bill Bowes

Hi

Thank you Jonathan,
I have managed to get the macro code in the Word document to work in IE if I
use the Ctrl+P keyboard shortcut, but not if I use the File|Print menu
command.

I cant seem to be able to modify the IE menu's as I can in Word.

I would like to disable the Menu items, or even present the document in a
blank IE window. Is this possible?
 
R

Russ

As Jonathan mentioned VBA doesn't have any IE objects to control. You are
better off going to javascript to control IE (or other browsers and
platforms). Try to google the other the forums that deal with those
subjects.
 
R

Russ

Apparently you can control IE in VB (close cousin to VBA), see sample
snippet below.
Ask you question in this forum where I got the snippet found through a
google search:
http://www.xtremevbtalk.com/

Dim IE as object
Set IE = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
IE.Navigate "http://www.google.com"
'go to web page listed inside quotes
IE.Visible = True
While IE.busy
DoEvents 'wait until IE is done loading page.
Wend
IE.Document.All("txt1").Value = "what you want to put in text box"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top