How do I put these into a submit button on the form. I have created the button I just need to know how to make it do the functions below.
<<<<<Below this line I would like to go inside my submit button>>>>>
Sub Save_File()
Dim SaveName As String
SaveName = ActiveSheet.Range("A1").Text
ActiveWorkbook.SaveAs Filename:="\\servername\share\\forms\" & _
SaveName & ".xls"
End Sub
'Will Email Document
Sub SendMail1()
'need a reference to MS Outlook object library
Dim olFolder As Outlook.MAPIFolder
Dim olMailItem As Outlook.MailItem
Dim olContact As Outlook.Recipient
Dim r, ToContact
Set olFolder = GetObject("", _
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
For r = 1 To LastRow(ActiveSheet)
If Trim(ActiveSheet.Cells(r, 1)) <> "" Then
Set olMailItem = olFolder.Items.Add ' creates a new e-mail message
With olMailItem
.Subject = "KCI SSR has been created file link enclosed" ' message subject
Set olContact = .Recipients.Add(ActiveSheet.Cells(2, 1)) ' add To recip
If Trim(ActiveSheet.Cells(r, 2)) <> "" Then 'set up cc if email address available
Set olContact = .Recipients.Add(ActiveSheet.Cells(r, 2)) ' add cc recipient
olContact.Type = olCC ' set latest recipient as CC
End If
.Body = " SSR has been created to view/edit please click following link " & ActiveSheet.Cells(1, 3) & vbCrLf & vbCrLf & "Regards" & vbCrLf & "IT"
.Send ' sends the e-mail message (puts it in the Outbox)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
End If
Next r
Set olFolder = Nothing
End Sub
Function LastRow(ws As Worksheet) As Single
'uses worksheet object
'returns last used row
On Error Resume Next
With ws
LastRow = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
End With
End Function
Bookmarks