Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Disable Printer In Word 1

Status
Not open for further replies.

jcmv007

Technical User
Nov 1, 2001
88
US
I'M Using:
Word 2002 SP-1
Windows XP SP-1

I need to write code to do a specific operation in a Word document. When the file is opened I would like to prompt the user a question he or she would like to print a controled copy of the document. If the anwser is Yes then get the last copy number from the PageFooter add 1 to it and append todays date. If the anwser is NO then disable the Printer.

Here is the code to gets the info from the user:
Code:
Private Sub Document_Open()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim Message, InputBox_Title, Default, MyValue

'MsgBox Info
Msg = "Would you like to print Controled Copy?"    ' Define message.
Style = vbYesNo + vbInformation + vbDefaultButton2    ' Define buttons.
Title = "Copia Controlada"    ' Define title.

'InputBox Info
Message = "Enter a value"    ' Set prompt.
Title2 = "Controled Copy Value"    ' Set title.
Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then    ' User chose Yes.
    MyValue = InputBox(Message, Title, , 100, 100)
    MyValue = MyValue & "_" & Date
    
Else    ' User chose No.
    'Disable Printer
            
End If

End Sub

Here is the code for updating the footer info.:
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 22/08/2003 by James McFarlane
'
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    If Selection.HeaderFooter.IsHeader = True Then
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Else
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    End If
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.MoveRight Unit:=wdCell
    Selection.TypeText Text:=&quot;001-22/08/2003&quot;
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
 
Hi jcmv007,

you can manipulate the standard Word functionality. I think thats the best place to put your code for what you want.

It would look something like this:

Public Sub FilePrint()
Dim iAnswer As Integer

'your code here
'.....
'.....
iAnswer = MsgBox(&quot;Would you like to print Controled Copy?&quot;, vbYesNo, &quot;Question&quot;)

If iAnswer = vbYes Then
'your code here
'.....
'.....

'then show print window
Application.Dialogs(wdDialogFilePrint).Show

Else 'if answer is no

MsgBox &quot;Printing is diabled&quot;

End If

End Sub

Public Sub FilePrintDefault()

'call FilePrint to handle this printing option
'in the same way as when a user picks the print option from
'the standard Word menubar

Call FilePrint

End Sub

FilePrint = the standard functionality from the Word menubar
FilePrintDefault = the standard functionality from the Word iconbar

Hope this helps.

Regards,
Unica
 
unica

Thank you very much it worked GREAT!

Have a Star!


James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top