Trap the Send-To event

O

Otto Moehrbach

Excel XP & Win XP
I need to increment an Invoice number before each time the Invoice sheet is
either printed or emailed ( File - Send-To). The print and Send-To commands
are manually, not VBA, issued
The printed part I know, but is there a way to trap the Send-To event to run
some code?
Thanks for your time. Otto
 
P

Peter T

Hi Otto,

You could trap the button click event. You didn't say which Send-to, you
have a bit control over Routing but not mail, if say user doesn't complete
the email.

'''code in normal module

Dim colButtons As Collection

Sub SinkClickEvents()
Dim ctl As CommandBarButton
Dim i As Long
Dim nID As Long
Dim vaID, vaAction
Dim cls As Class1
vaID = Array(3738, 2188, 259)
vaAction = Array("SendToMail", "SendToRecipient", "SendToRouting")

Set colButtons = New Collection
For i = LBound(vaID) To UBound(vaID)
Set ctl = Application.CommandBars.FindControl(ID:=vaID(i))
Set cls = New Class1
Set cls.pBtn = ctl
cls.psAction = vaAction(i)
colButtons.Add cls, vaAction(i)
Next
End Sub

''''''''''''''''''''''''''''''

''''code in Class1 < rename
Public WithEvents pBtn As CommandBarButton
Public psAction As String

Private Sub pBtn_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
Dim bDlgRes As Boolean
MsgBox psAction
Select Case psAction
Case "SendToMail"
'code
Case "SendToRecipient"
'code
Case "SendToRouting"
CancelDefault = True
bDlgRes = Application.Dialogs(xlDialogRoutingSlip).Show
MsgBox "User " & IIf(bDlgRes, "processed", "pressed cancel"), , psAction
'code
End Select
End Sub

Regards,
Peter T
 

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