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:
Here is the code for updating the footer info.:
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:="001-22/08/2003"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub