Humbled
08-01-2008, 03:13 AM
My document will be retrieved by users from a website or shared drive. The document is a form, and through macro magic (found on this forum) emails the completed form via Outlook to a mailbox.
I am currently renaming the document and then sending. I need the doc sent to the mailbox to have a specific name so those who handle the form have some idea about what's needed before they open it. This works.
'************************************************************
' Rename document to ROC-CUST-TIMESTAMP then save it
'************************************************************
Store = ActiveDocument.Bookmarks("PHCY").Range.Text
SvTime = Format(Now, "yymmdd") & Format(Now, "hhmmss")
FileName = "ROC-" & Store & " " & SvTime
ActiveDocument.SaveAs FileName
'************************************************************
' Open a new e-mail message
'************************************************************
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = email.addy@myplace.com 'send to this address
.Subject = Store & " [" & strTYP & " " & Format(NeedDt, "yymmdd") & "]"
.Body = "See attached document." ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With
Now ... since a copy will be saved in the user's sent items folder, there's really no need to keep a local copy. I'd like to rename (or assign a new name) without the SaveAs.
The following doesn't work ... complains about a read-only property.
'************************************************************
' Rename document to ROC-CUST-TIMESTAMP then save it
'************************************************************
Store = ActiveDocument.Bookmarks("PHCY").Range.Text
SvTime = Format(Now, "yymmdd") & Format(Now, "hhmmss")
FileName = "ROC-" & Store & " " & SvTime
ActiveDocument.Name = FileName
As a last resort, I suppose I could save it, email it, then delete it - but hoping for something other than a last resort.
Thanks in advance.
I am currently renaming the document and then sending. I need the doc sent to the mailbox to have a specific name so those who handle the form have some idea about what's needed before they open it. This works.
'************************************************************
' Rename document to ROC-CUST-TIMESTAMP then save it
'************************************************************
Store = ActiveDocument.Bookmarks("PHCY").Range.Text
SvTime = Format(Now, "yymmdd") & Format(Now, "hhmmss")
FileName = "ROC-" & Store & " " & SvTime
ActiveDocument.SaveAs FileName
'************************************************************
' Open a new e-mail message
'************************************************************
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = email.addy@myplace.com 'send to this address
.Subject = Store & " [" & strTYP & " " & Format(NeedDt, "yymmdd") & "]"
.Body = "See attached document." ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With
Now ... since a copy will be saved in the user's sent items folder, there's really no need to keep a local copy. I'd like to rename (or assign a new name) without the SaveAs.
The following doesn't work ... complains about a read-only property.
'************************************************************
' Rename document to ROC-CUST-TIMESTAMP then save it
'************************************************************
Store = ActiveDocument.Bookmarks("PHCY").Range.Text
SvTime = Format(Now, "yymmdd") & Format(Now, "hhmmss")
FileName = "ROC-" & Store & " " & SvTime
ActiveDocument.Name = FileName
As a last resort, I suppose I could save it, email it, then delete it - but hoping for something other than a last resort.
Thanks in advance.