brettdj
09-06-2005, 09:55 PM
is this possible?
I have stripped out word resumes and cover letter from 120 email messages on my hard drive using Redemption and File Scripting
I now want to print all files - simple question, do I have to open them?
http://support.microsoft.com/?kbid=201993 says this can be done, although this code fails for me, even when I use the full path
Sub ListDocNamesInFolder()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain the files.
sMyDir = "C:\My Documents\"
sDocName = Dir(sMyDir & "*.DOC")
While sDocName <> ""
' Print the file.
Application.PrintOut FileName: = sDocName
' Get next file name.
sDocName = Dir()
Wend
End Sub
my code
Sub PrintRes()
Dim oApp As Outlook.Application
Dim sItem, oItem
Dim fso As FileSystemObject, fol As Folder, fil As File, a As Attachment
Dim MsgPath As String, SecondSpace As String, Fname As String
MsgPath = "c:\sba"
Set oApp = New Outlook.Application
Set sItem = CreateObject("Redemption.SafeMailItem")
Set oItem = oApp.Session.GetDefaultFolder(16).Items.Add(6)
Set fso = New FileSystemObject
Set fol = fso.GetFolder(MsgPath)
If fso.FolderExists(MsgPath & "\resumes\") = False Then fso.CreateFolder (MsgPath & "\resumes")
For Each fil In fol.Files
sItem.Item = oItem
sItem.Import fil.Path, 3
SecondSpace = InStr(sItem.Item.Subject, " ")
SecondSpace = InStr(SecondSpace + 1, sItem.Item.Subject, " ")
For Each a In sItem.Attachments
Fname = MsgPath & "\resumes\" & Left(sItem.Item.Subject, SecondSpace) & a.Filename
If Right(a.Filename, 3) = "doc" Then a.SaveAsFile Fname
'Application.PrintOut Filename:=Fname
Next
Next
End Sub
I have stripped out word resumes and cover letter from 120 email messages on my hard drive using Redemption and File Scripting
I now want to print all files - simple question, do I have to open them?
http://support.microsoft.com/?kbid=201993 says this can be done, although this code fails for me, even when I use the full path
Sub ListDocNamesInFolder()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain the files.
sMyDir = "C:\My Documents\"
sDocName = Dir(sMyDir & "*.DOC")
While sDocName <> ""
' Print the file.
Application.PrintOut FileName: = sDocName
' Get next file name.
sDocName = Dir()
Wend
End Sub
my code
Sub PrintRes()
Dim oApp As Outlook.Application
Dim sItem, oItem
Dim fso As FileSystemObject, fol As Folder, fil As File, a As Attachment
Dim MsgPath As String, SecondSpace As String, Fname As String
MsgPath = "c:\sba"
Set oApp = New Outlook.Application
Set sItem = CreateObject("Redemption.SafeMailItem")
Set oItem = oApp.Session.GetDefaultFolder(16).Items.Add(6)
Set fso = New FileSystemObject
Set fol = fso.GetFolder(MsgPath)
If fso.FolderExists(MsgPath & "\resumes\") = False Then fso.CreateFolder (MsgPath & "\resumes")
For Each fil In fol.Files
sItem.Item = oItem
sItem.Import fil.Path, 3
SecondSpace = InStr(sItem.Item.Subject, " ")
SecondSpace = InStr(SecondSpace + 1, sItem.Item.Subject, " ")
For Each a In sItem.Attachments
Fname = MsgPath & "\resumes\" & Left(sItem.Item.Subject, SecondSpace) & a.Filename
If Right(a.Filename, 3) = "doc" Then a.SaveAsFile Fname
'Application.PrintOut Filename:=Fname
Next
Next
End Sub