H
Hogan's Goat
I found this code online which works really excellent once you
reference Outlook:
Sub sendmyfilesomewhereplease
ActiveWorkbook.SaveAs FileName:="C:\MyFiles\my new excel file.xls"
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
With myItem
..Recipients.Add "John Q (e-mail address removed)"
..body = "This is the message text"
..Subject = "This is my message subject"
End With
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\MyFiles\my new excel file.xls", _
olByValue, 1, "My file transmission"
myItem.Send
End Sub
However, the attachment part isn't quite what I would want. Instead of
hard-coding the file and path, I would rather just have it call
ActiveWorkbook. I'm a cruddy coder, so I just put Activeworkbook in
there and it didn't work.
How would I make it work? I realize I'm trying to call an Excel object
from within a call to an Outlook app, but I don't know how to tell
Outlook to do that. Any suggestions? Thanks!
reference Outlook:
Sub sendmyfilesomewhereplease
ActiveWorkbook.SaveAs FileName:="C:\MyFiles\my new excel file.xls"
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
With myItem
..Recipients.Add "John Q (e-mail address removed)"
..body = "This is the message text"
..Subject = "This is my message subject"
End With
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\MyFiles\my new excel file.xls", _
olByValue, 1, "My file transmission"
myItem.Send
End Sub
However, the attachment part isn't quite what I would want. Instead of
hard-coding the file and path, I would rather just have it call
ActiveWorkbook. I'm a cruddy coder, so I just put Activeworkbook in
there and it didn't work.
How would I make it work? I realize I'm trying to call an Excel object
from within a call to an Outlook app, but I don't know how to tell
Outlook to do that. Any suggestions? Thanks!