Print options

A

Angyl

I have a form with my boss's signature (image) on the line, but he isn't the
one who will always be "signing" the form.

Is there a way I could make a macro to run on file.print that would ask

"Is Greg signing this form?"

And if the user chooses "yes" then to print pages 1-3 of the form, and if
the user chooses "no" then print pages 1,2 and 4 (4 would be a duplicate of
the signer's page but without the signature image).
 
J

Jean-Guy Marcil

Angyl was telling us:
Angyl nous racontait que :
I have a form with my boss's signature (image) on the line, but he
isn't the one who will always be "signing" the form.

Is there a way I could make a macro to run on file.print that would
ask

"Is Greg signing this form?"

And if the user chooses "yes" then to print pages 1-3 of the form,
and if the user chooses "no" then print pages 1,2 and 4 (4 would be a
duplicate of the signer's page but without the signature image).

Instead of dealing with double pages, may I suggest the following?
Read all the comments in the code, test it and write back if you need more
help.
This code should be in the template, not the document itself.

If you do not have a template, I strongly recommend that you make one.

For more information on templates and macros, you should have a look at:
http://word.mvps.org/faqs/customization/CreateATemplatePart1.htm
http://word.mvps.org/faqs/customization/CreateATemplatePart2.htm
http://word.mvps.org/faqs/macrosvba/DistributeMacros.htm
http://word.mvps.org/faqs/Customization/WhatTemplatesStore.htm

'_______________________________________
Private Const shpSigName As String = "MyBossSig"
'_______________________________________
Sub AssignName()
'To give a name to the signature image.
'Select the image and then run this sub.
'It must be a floating image (not inline),
'only need to run this sub once in the template
'when setting it up.

Selection.ShapeRange(1).Name = shpSigName

End Sub
'_______________________________________

'_______________________________________
Function AskForSig() As Integer
'To ask question whether Greg is signing or not
'and to return the answer/result to the
'calling sub via Function value

Const myQuestion As String = "Is Greg signing this form?"
Const myTitle As String = "Signature"

AskForSig = MsgBox(myQuestion, _
vbInformation + vbYesNoCancel, myTitle)

End Function
'_______________________________________

'_______________________________________
Sub myPrint(boolAll As Boolean)
'Use boolean variable (boolAll) as function parameter so
'as to know if user called this sub from the menu
'or toolbar, i.e should we display the print dialog or
'automatically print out the document

'Variable to store result of question:
Dim myResult As Integer

'Ask question and return answer
myResult = AskForSig

'Act according to answer/result
Select Case myResult
Case 6 'Yes
'in case you want to do other stuff, put code here
Case 7 'No
ActiveDocument.Shapes(shpSigName).Visible = False
Case 2 'Cancel
Exit Sub
End Select

If boolAll Then
ActiveDocument.PrintOut
Else
Dialogs(wdDialogFilePrint).Show
End If

If myResult = 7 Then
ActiveDocument.Shapes(shpSigName).Visible = True
End If

End Sub
'_______________________________________

'_______________________________________
Sub FilePrint()
'This is executed when user does File > Print or CTRL-P

'Call print sub passing the appropriate parameter
myPrint False

End Sub
'_______________________________________

'_______________________________________
Sub FilePrintDefault()
'This is executed when user clicks on the
'Printer icon on the standard toolbar

'Call print sub passing the appropriate parameter
myPrint True

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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