f100engineer
Technical User
Hi, 1st post here.
I am trying to automate a morning story report for my company. Before I took this position, someone had made code to do it, but it isn't totally automated and the code is long. I think it could be simplified.
Here's the old code:
Private Sub Output_Composite_Sto_Click()
On Error GoTo Output_Composit_Sto_Click_Error
Dim sFileName As String
Dim TaskID As Variant
sReportName = "Composite Morning Story"
sFileName = "C:\f100CMornstor.doc"
DoCmd.OutputTo acOutputReport, sReportName, acFormatRTF, sFileName, True
glrDelay (2000)
SendKeys "^a^c", True
TaskID = Shell("C:\Program Files\Exchange\Exchng32.exe", vbMaximizedFocus)
'start new message
glrDelay (2000)
SendKeys "%mn", True
glrDelay (1000) ' 1 second delay
'Default location is the "to" field, tabs move to the next field
SendKeys "F100 composite Dept 742{TAB}{TAB}F100 Composite Morning Story{TAB}^v"
'next step is "^V" which has problems
'so manual pass this point
Output_Composit_Sto_Click_Exit:
Exit Sub
Output_Composit_Sto_Click_Error:
Select Case Err.Number
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description, , "Composite Morning Story"
Resume Output_Composit_Sto_Click_Exit
End Select
End Sub
Here is the newer code I am trying:
DoCmd.SendObject acSendReport, "Composite Morning Story", acFormatRTF, morning story,,"F100 Composite Morning Story",,False
It opens up an email with the TO filled out correct, the SUBJECT filled out correct, and attached Word doc in the body. But it doesn't automatically send the email. I thought that is what the last part "false" was for.
Also, at attaches the report to the email as an attachment. I would rather it paste its text into the email. Is there a way to do this?
ONE more question. I would like to be able to add the current date to the end of the subject line, but haven't had any luck finding a way to do this.
TIA,
-S.Huskins
I am trying to automate a morning story report for my company. Before I took this position, someone had made code to do it, but it isn't totally automated and the code is long. I think it could be simplified.
Here's the old code:
Private Sub Output_Composite_Sto_Click()
On Error GoTo Output_Composit_Sto_Click_Error
Dim sFileName As String
Dim TaskID As Variant
sReportName = "Composite Morning Story"
sFileName = "C:\f100CMornstor.doc"
DoCmd.OutputTo acOutputReport, sReportName, acFormatRTF, sFileName, True
glrDelay (2000)
SendKeys "^a^c", True
TaskID = Shell("C:\Program Files\Exchange\Exchng32.exe", vbMaximizedFocus)
'start new message
glrDelay (2000)
SendKeys "%mn", True
glrDelay (1000) ' 1 second delay
'Default location is the "to" field, tabs move to the next field
SendKeys "F100 composite Dept 742{TAB}{TAB}F100 Composite Morning Story{TAB}^v"
'next step is "^V" which has problems
'so manual pass this point
Output_Composit_Sto_Click_Exit:
Exit Sub
Output_Composit_Sto_Click_Error:
Select Case Err.Number
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description, , "Composite Morning Story"
Resume Output_Composit_Sto_Click_Exit
End Select
End Sub
Here is the newer code I am trying:
DoCmd.SendObject acSendReport, "Composite Morning Story", acFormatRTF, morning story,,"F100 Composite Morning Story",,False
It opens up an email with the TO filled out correct, the SUBJECT filled out correct, and attached Word doc in the body. But it doesn't automatically send the email. I thought that is what the last part "false" was for.
Also, at attaches the report to the email as an attachment. I would rather it paste its text into the email. Is there a way to do this?
ONE more question. I would like to be able to add the current date to the end of the subject line, but haven't had any luck finding a way to do this.
TIA,
-S.Huskins