T
Tim
First I would like to qualify; I’m not a programmer, far from it. I’m a
police officer that is trying to take my agency from the pen and paper era to
this ‘new’ era called the ‘computer age’. I have been working on this project
(on my own time) for about two years. Everything that I learned so far has
been from this discussion group or a site that I was directed to. I would
like to say thanks to all the people that helped/directed me, written code,
etc., without your help I would have given up a long time ago.
OK enough sucking up. Here is my next project. I would like to try and add
some Userforms to the program. I’ve done a little homework and so far I’ve
been able to build the form, now I need it to do what I want it to.
I plan to have a button on ‘Sheet 1’ that calls the form up. The form has
six text boxes on it (txtDate, txtName, txtPerson, txtTime, txtRelease,
TxtNextdate). I would like the data from those text fields to go to specific
cells on a sheet named ‘Employee List’. i.e. txtDate to G45. I would then
like it to run the following email code (that I found on Ron Debruin’s site,
Thanks Ron). I would like person to be able to fill in the boxes and then
click on one button on the form (cmdEmailtodata) and have it do both
processes.
Sorry for the long post.
Thanks
Private Declare Function ShellExecute Lib "Shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, _
ByVal nShowCmd As Long) As Long
________________________________________________________________________
Sub Mail_Text_in_Body_3()
'Creates statement for person and emails it to data entry
Dim msg As String, URL As String
Dim Recipient As String, Subj As String
Dim cell As Range
Recipient = "(e-mail address removed)"
Subj = "Statement for " & " for Incident " & Sheets("Employee
List").Range("N7").Value
msg = "Statement of " & vbNewLine & vbNewLine
For Each cell In Sheets("Employee List").Range("N3")
msg = msg & vbNewLine & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%0D%0A")
msg = WorksheetFunction.Substitute(msg, vbLf, "%0D%0A")
URL = "mailto:" & Recipient & "&subject=" & Subj & "&body=" & msg
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString,
vbNormalFocus
Application.Wait (Now + TimeValue("0:00:03"))
Application.SendKeys "%s"
End Sub
police officer that is trying to take my agency from the pen and paper era to
this ‘new’ era called the ‘computer age’. I have been working on this project
(on my own time) for about two years. Everything that I learned so far has
been from this discussion group or a site that I was directed to. I would
like to say thanks to all the people that helped/directed me, written code,
etc., without your help I would have given up a long time ago.
OK enough sucking up. Here is my next project. I would like to try and add
some Userforms to the program. I’ve done a little homework and so far I’ve
been able to build the form, now I need it to do what I want it to.
I plan to have a button on ‘Sheet 1’ that calls the form up. The form has
six text boxes on it (txtDate, txtName, txtPerson, txtTime, txtRelease,
TxtNextdate). I would like the data from those text fields to go to specific
cells on a sheet named ‘Employee List’. i.e. txtDate to G45. I would then
like it to run the following email code (that I found on Ron Debruin’s site,
Thanks Ron). I would like person to be able to fill in the boxes and then
click on one button on the form (cmdEmailtodata) and have it do both
processes.
Sorry for the long post.
Thanks
Private Declare Function ShellExecute Lib "Shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, _
ByVal nShowCmd As Long) As Long
________________________________________________________________________
Sub Mail_Text_in_Body_3()
'Creates statement for person and emails it to data entry
Dim msg As String, URL As String
Dim Recipient As String, Subj As String
Dim cell As Range
Recipient = "(e-mail address removed)"
Subj = "Statement for " & " for Incident " & Sheets("Employee
List").Range("N7").Value
msg = "Statement of " & vbNewLine & vbNewLine
For Each cell In Sheets("Employee List").Range("N3")
msg = msg & vbNewLine & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%0D%0A")
msg = WorksheetFunction.Substitute(msg, vbLf, "%0D%0A")
URL = "mailto:" & Recipient & "&subject=" & Subj & "&body=" & msg
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString,
vbNormalFocus
Application.Wait (Now + TimeValue("0:00:03"))
Application.SendKeys "%s"
End Sub