Tip

Disable print command in Microsoft Word

This agent connects to Microsoft Word and disables the Print command in Word. It is done through Lotusscript. To enable the Print command, you need to set the control enable property to true.


'This script disables the print command in Menubar of Microsoft word



Sub Initialize
	Dim xlFilename As String
	
	Dim session As New NotesSession
	xlFilename="C:\Book2.doc"     'Any word document to be opened
	Dim db As NotesDatabase       
	Dim doc As NotesDocument
	Dim w As New NotesUIWorkspace
	Dim WordDocs As Variant        
	Dim WordDoc As Variant
	
	Dim oMainMenuBar As Variant   'Handle of the Word Menubar
	Dim submenu As Variant			 'Handle of the Print command in the Menubar
	Dim submenu1 As Variant
	Dim control1 As Variant
	Dim control2 As Variant
	
	Dim object As Variant
	Dim WordObj As Variant
	
	Dim prints As Variant
	
	Dim workspace As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Set uidoc = workspace.CurrentDocument
	
	Set db = session.CurrentDatabase
	
	
	Set WordObj = CreateObject("Word.Application")           'Create a word object
	WordObj.visible = True                                    'To make the word document visible
	Set WordDocs = WordObj.Documents
	
	Print "Opening.." & xlFilename &"...."
	WordObj.Documents.Open xlFilename        'Opens the required filename
	Set WordDoc = WordObj.ActiveDocument       
	
	Set oMainMenuBar = WordObj.CommandBars.Item("Menu Bar")
	Set submenu=oMainMenuBar.Controls("&File")    'Initializes with the menubar control
'	Set submenu1=oMainMenuBar.Controls("&Edit")
	Set control1=submenu.Controls("&Print...")        'Initializes with the Print control
'	Set control2=submenu.Controls("&Close")
	control1.Enabled=False                'Set to false disables the command on the Menubar
'	control2.Enabled=True
End Sub

This was first published in October 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.