Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default RECORD SENT EMAIL

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default RECORD SENT EMAIL

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default RECORD SENT EMAIL

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?

2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?

4) If I also wanted to include the body, would I include strBody as string
and add range D?

Thanks so much for your speedy response and your help. Pam

"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default RECORD SENT EMAIL

Please find the below comments aganist your points and the modified code

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Dim strReceipients As String
Dim strBody As String
strReceipients = <to string
strBody = Range("A1").Text
Call WritetoLog(strReceipients, Range("A1"))

End Sub
Sub WritetoLog(strTo As String, strBody As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & lngRow) = <call your function here
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = strBody
ws.Range("D" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?


Sure, you can do that; can call the function within the procedure...


2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?


If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?

Pam was in place of strTo....In the modified one pass the receipients to the
variable


4) If I also wanted to include the body, would I include strBody as string
and add range D?


Check the modified code..


Thanks so much for your speedy response and your help. Pam


You are always welcome..


"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default RECORD SENT EMAIL

Jacob; I am getting a compile error on
strReceipients = <to string


"Jacob Skaria" wrote:

Please find the below comments aganist your points and the modified code

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Dim strReceipients As String
Dim strBody As String
strReceipients = <to string
strBody = Range("A1").Text
Call WritetoLog(strReceipients, Range("A1"))

End Sub
Sub WritetoLog(strTo As String, strBody As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & lngRow) = <call your function here
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = strBody
ws.Range("D" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?


Sure, you can do that; can call the function within the procedure...


2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?


If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?

Pam was in place of strTo....In the modified one pass the receipients to the
variable


4) If I also wanted to include the body, would I include strBody as string
and add range D?


Check the modified code..


Thanks so much for your speedy response and your help. Pam


You are always welcome..


"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default RECORD SENT EMAIL

strReceipients = "You need to enter the receipeints within this doule quotes"

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; I am getting a compile error on
strReceipients = <to string


"Jacob Skaria" wrote:

Please find the below comments aganist your points and the modified code

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Dim strReceipients As String
Dim strBody As String
strReceipients = <to string
strBody = Range("A1").Text
Call WritetoLog(strReceipients, Range("A1"))

End Sub
Sub WritetoLog(strTo As String, strBody As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & lngRow) = <call your function here
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = strBody
ws.Range("D" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?


Sure, you can do that; can call the function within the procedure...


2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?


If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?

Pam was in place of strTo....In the modified one pass the receipients to the
variable


4) If I also wanted to include the body, would I include strBody as string
and add range D?


Check the modified code..


Thanks so much for your speedy response and your help. Pam


You are always welcome..


"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default RECORD SENT EMAIL

Its variable each time the button is used. If I want all recipients, what
would I enter?

"Jacob Skaria" wrote:

strReceipients = "You need to enter the receipeints within this doule quotes"

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; I am getting a compile error on
strReceipients = <to string


"Jacob Skaria" wrote:

Please find the below comments aganist your points and the modified code

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Dim strReceipients As String
Dim strBody As String
strReceipients = <to string
strBody = Range("A1").Text
Call WritetoLog(strReceipients, Range("A1"))

End Sub
Sub WritetoLog(strTo As String, strBody As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & lngRow) = <call your function here
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = strBody
ws.Range("D" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?

Sure, you can do that; can call the function within the procedure...


2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?

If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?
Pam was in place of strTo....In the modified one pass the receipients to the
variable


4) If I also wanted to include the body, would I include strBody as string
and add range D?

Check the modified code..


Thanks so much for your speedy response and your help. Pam

You are always welcome..


"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default RECORD SENT EMAIL

Pass your variable with the recepients.. or if it is in a range cell A1
strReceipients = Range("A1")

From previous post

2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?

If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Its variable each time the button is used. If I want all recipients, what
would I enter?

"Jacob Skaria" wrote:

strReceipients = "You need to enter the receipeints within this doule quotes"

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; I am getting a compile error on
strReceipients = <to string


"Jacob Skaria" wrote:

Please find the below comments aganist your points and the modified code

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Dim strReceipients As String
Dim strBody As String
strReceipients = <to string
strBody = Range("A1").Text
Call WritetoLog(strReceipients, Range("A1"))

End Sub
Sub WritetoLog(strTo As String, strBody As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & lngRow) = <call your function here
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = strBody
ws.Range("D" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

Jacob; Very cool! I know enough to be dangerous and am self teaching here.
Couple of questions:

1) In WritetoLog where you have Environ "username", --is that calling my
function for username? If so, if my function is actually called
UserNameWindows, I'm thinking I would replace that with my function name?

Sure, you can do that; can call the function within the procedure...


2) I tested multiple addresses and code picks up only one. How can I
include all addressees in a string?

If you have the to addresses as a string pass that to strReceipients or
replace that with your variable..If you have it in a range you can loop and
store that to a variable

3) To capture every user who uses the button, what would my variable be in
place of Pam? An *?
Pam was in place of strTo....In the modified one pass the receipients to the
variable


4) If I also wanted to include the body, would I include strBody as string
and add range D?

Check the modified code..


Thanks so much for your speedy response and your help. Pam

You are always welcome..


"Jacob Skaria" wrote:

Hi Pam

Use the below proceudre ...WritetoLog..

Sub Macro()
'your code to send mail starts here
'
'your code to send mail ends here

Call WritetoLog(Environ("Username"), "Pam")
'you can replace the username with a variable
'strTo is the mailTo as a string variable

End Sub

Replace the sheet name ...
Sub WritetoLog(strUser As String, strTo As String)
Dim ws As Worksheet, lngRow As Long
Set ws = Worksheets("Sheet1")
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws.Range("A" & lngRow) = strUser
ws.Range("B" & lngRow) = strTo
ws.Range("C" & lngRow) = Now
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a macro that enables the user to send an email from an excel
application. It is attached to a button. Is there a way to add code that
would populate a cell each time that button is used (or the macro is run)? I
would like it to add a line each time, not write it over. I want it to
capture the username, which I have as a function in VB, date, time, and To:.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new record with selected fields from previous record Design by Sue Excel Discussion (Misc queries) 1 June 12th 09 02:24 PM
Email distribution of Access Record Snyderm Excel Discussion (Misc queries) 1 March 28th 09 12:28 AM
email out Pivot Chart with one record only QuocAnh[_2_] Excel Programming 5 October 30th 07 07:02 AM
How do I email just one record from an excel database. sunbelt vacuum Excel Discussion (Misc queries) 2 August 8th 06 09:53 PM
Record Macro - Record custom user actions Sal[_4_] Excel Programming 1 December 23rd 04 03:18 PM


All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"