![]() |
Record the time a user selects a macro
I have an excel file I am creating to use as a work flow. I have added button for the user to have the file attach in lotus notes and be route to the next approprate person. I would like to add the function fo macro to record the time, input it in a cell, then email the file. M code is below: Where and what would I add to do this? Sub DL_email() Dim noSession As Object, noDatabase As Object, noDocument A Object Dim obAttachment As Object, EmbedObject As Object Dim stSubject As Variant, stAttachment As String Dim vaRecipient As Variant, vaMsg As Variant Const EMBED_ATTACHMENT As Long = 1454 Const stTitle As String = "Active workbook status" Const stMsg As String = "The active workbook must first be saved & vbCrLf _ & "before it can be sent as an attachment." 'Check if the active workbook is saved or not 'If the active workbook has not been saved at all. If Len(ActiveWorkbook.Path) = 0 Then MsgBox stMsg, vbInformation, stTitle Exit Sub End If 'If the changes in the active workbook have been saved or not. If ActiveWorkbook.Saved = False Then If MsgBox("Do you want to save the changes before sending?", _ vbYesNo + vbInformation, stTitle) = vbYes Then _ ActiveWorkbook.Save End If vaRecipient = " stSubject = "DL e-procurement setup form" 'Retrieve the path and filename of the active workbook. stAttachment = ActiveWorkbook.FullName 'Instantiate the Lotus Notes COM's Objects. Set noSession = CreateObject("Notes.NotesSession") Set noDatabase = noSession.GETDATABASE("", "") 'If Lotus Notes is not open then open the mail-part of it. If noDatabase.IsOpen = False Then noDatabase.OPENMAIL 'Create the e-mail and the attachment. Set noDocument = noDatabase.CreateDocument Set obAttachment = noDocument.CreateRichTextItem("stAttachment") Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, "" stAttachment) 'Add values to the created e-mail main properties. With noDocument .Form = "Memo" .SendTo = vaRecipient .Subject = stSubject .SaveMessageOnSend = True End With 'Send the e-mail. With noDocument .PostedDate = Now() .Send 0, vaRecipient End With 'Release objects from the memory. Set EmbedObject = Nothing Set obAttachment = Nothing Set noDocument = Nothing Set noDatabase = Nothing Set noSession = Nothing 'Activate Excel for the user. AppActivate "Microsoft Excel" MsgBox "The e-mail has successfully been sent.", vbInformation End Sub thanks, marcus -- marcusmccow ----------------------------------------------------------------------- marcusmccown's Profile: http://www.excelforum.com/member.php...fo&userid=3569 View this thread: http://www.excelforum.com/showthread.php?threadid=55482 |
All times are GMT +1. The time now is 09:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com