B
bstevens
I've been using the macro below (I got this from the Outlook VBA help
file - I'm not a heavy duty coder) to save selected email to a folder
on a hard drive. Users will be saving hundreds and hundreds of emails
in this manner, so I'm trying to automate it as much as possible.
I need to change two things:
1. Instead of naming the file using the "Subject:" string, open a box
so the user can name it.
2. In #1, the user will always enter a 6-digit number, e.g. "987021"
as the file name. A critical point is that over several months, the
user will save several files with the same name. When that happens,
the new file can NOT "replace the existing file by the same name."
There are two possible approaches to this:
One approach is to allow multiple files to be saved with the same
name. Maybe something like 987021-2, 987021-3, and so on, or whatever
could work. The user can NOT enter this "-2" or "-3" suffix, it needs
to be automatic. In any case, the user can only enter the 6-digit file
name.
A better approach would be where if the filename already exists, it
would catenate the new file to the existing one, instead of creating a
new one. I have utterly no idea how to do that. This approach would
actually be MUCH more preferable than the first one.
These two fixes would be enormously appreciated, and would save
several people a huge quantity of time and work.
Please reply only on the newsgroup.
Thanks,
Bill S.
Here's the current code:
******************************************
Sub saveemail()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the item? If a file
with the same name already exists, it will be overwritten with this
copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs "S:\Funding Team\Communication\Region
1\Calendar Year 2007\" & strname & ".txt", olTXT
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub
file - I'm not a heavy duty coder) to save selected email to a folder
on a hard drive. Users will be saving hundreds and hundreds of emails
in this manner, so I'm trying to automate it as much as possible.
I need to change two things:
1. Instead of naming the file using the "Subject:" string, open a box
so the user can name it.
2. In #1, the user will always enter a 6-digit number, e.g. "987021"
as the file name. A critical point is that over several months, the
user will save several files with the same name. When that happens,
the new file can NOT "replace the existing file by the same name."
There are two possible approaches to this:
One approach is to allow multiple files to be saved with the same
name. Maybe something like 987021-2, 987021-3, and so on, or whatever
could work. The user can NOT enter this "-2" or "-3" suffix, it needs
to be automatic. In any case, the user can only enter the 6-digit file
name.
A better approach would be where if the filename already exists, it
would catenate the new file to the existing one, instead of creating a
new one. I have utterly no idea how to do that. This approach would
actually be MUCH more preferable than the first one.
These two fixes would be enormously appreciated, and would save
several people a huge quantity of time and work.
Please reply only on the newsgroup.
Thanks,
Bill S.
Here's the current code:
******************************************
Sub saveemail()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the item? If a file
with the same name already exists, it will be overwritten with this
copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs "S:\Funding Team\Communication\Region
1\Calendar Year 2007\" & strname & ".txt", olTXT
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub