Hi i have this problem and i need to solve it urgently. I already got the source code for 1 of the button but i need the same code to be use in 2 other button that is at the same document. It is possible to do it?
The following will be the source for the button Requestor Send:
Sub Click(Source As Button)
Dim arrSendTo( ) As Variant
Dim arrCopyTo( ) As Variant
Dim arrBlindCopyTo( ) As Variant
Dim ws As New NotesUIWorkspace
Dim doc As NotesDocument
Set doc = ws.CurrentDocument.Document
'Set mail memo fields
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set rtitem=New NotesRichTextItem(doc,"Body")
doc.Form="Memo"
doc.PostedDate= Now()
doc.ComposedDate= Now()
doc.DeliveryDate= Now()
For i=0 To Ubound(doc.pSendTo)
Redim Preserve arrSendTo(i+1)
arrSendTo(i)=doc.pSendTo(i)
Next
doc.SendTo=arrSendTo
For i=0 To Ubound(doc.pCopyTo)
Redim Preserve arrCopyTo(i+1)
arrCopyTo(i)=doc.pCopyTo(i)
Next
doc.CopyTo=arrCopyTo
For i=0 To Ubound(doc.pBlindCopyTo)
Redim Preserve arrBlindCopyTo(i+1)
arrBlindCopyTo(i)=doc.pBlindCopyTo(i)
Next
doc.BlindCopyTo=arrBlindCopyTo
'Try sending the mail
If fnCourier(arrSendTo,arrCopyTo,arrBlindCopyTo,_
doc,uidoc) Then
'Success
Messagebox "Success! E-mail has been send"
Else
'Failure
Messagebox "Fail! Unable to send this E-mail"
End If
End Sub
The other two button will be for Section Head Send and Head Logistic Send.
Thanks for a million
Subject: How to use 1 send Button code to 3different button at the same document
If the code is going to be identical for all three buttons, why not just put the code in a script library, then USE it in the three buttons?
Subject: RE: How to use 1 send Button code to 3different button at the same document
I know that i should make use of the script library bue how am i going to do that? what are the steps? Can you Help? I copt the code into the script then what should i do so that when i click the button i can call the script library?
Subject: How to use 1 send Button code to 3different button at the same document
Hi
First you have to create a new script library. Then you make a new sub in this lib and copied the code between Sub Click… and End Sub into it. When you save the lib for the first time, you wil ask to input a name for the lib (for example Tools).
Then you go back to your button. In the Declaration section you type Use “Tools” an in the Click sub you call the sub from the lib.
That’s all.
Regards and a happy new year.
Axel
Subject: RE: How to use 1 send Button code to 3different button at the same document
Do i have to also copy my main code to the script? coz if i dun copy the function script it will say illegal parenthesized reference: COURIER?
Then how do declare sub in the click from the library?
Thanks and Happy New Year Too!!
Subject: RE: How to use 1 send Button code to 3different button at the same document
Hi
in your Code in the Click event from the button is a function called fnCourier. You have to insert this function in your lib too.
You have to generate a new Sub in your script lib.
Ex.
Sub SendMails
'Code from Click-Event
End Sub
Cut the complete code form the Click-Event and paste it into the new sub.
In the Declaration section of the buttons insert Use “Name of your lib”
In the Click event enter the call of the sub.
Sub Click…
Call SendMails
End Sub
In the Designer’s online help there’s a lot of info for the usage of script libraries.
Regards
Axel
Subject: RE: How to use 1 send Button code to 3different button at the same document
Hi,Thanks for the help. I got it already.
Ivy