Hello
I was lucky to recieve some helpful advice regarding my new problem so if you wanted to read this the link is below.
Here is my new problem.
I have the following code.
Global file, monyear, day, report, Filepath As String
'******************************************************************
'Using WinRar within Excel
'Syntax
'
' RAR <command> [ -<switches> ] <archive> [ <@listfiles...> ]
' [ <files...> ] [ <path_to_extract\> ]
'******************************************************************
'*************
' Adding files
'*************
Sub WinRarIt()
' Opens the correct file for today
day = Format(Date, "d")
monyear = Format(Date, " mmm yyyy")
paths = day & OrdinalSuffix(day) & monyear
' function OrdinalSuffix(day) takes today's day and runs it throught the OrdinalSuffix() function
Filepath = "G:\MI Reports\" & paths & "\IntroducerMI\"
Dim WinRarPath As String 'WinRar.exe location
Dim RarIt As String 'Command line instruction
Dim SourceDir As String 'The source directory
Dim SourceFile As String 'The source file
Dim Source As String 'The combined Rar from path(s)(FROM)
Dim DestDir As String 'The Rarped file directory
Dim DestRarName As String 'The Rarped file
Dim Dest As String 'The combined Rar to path (TO)
Dim ClientName As String
Dim SendFile As String
Dim Email As String
Dim Password As String
Dim T As String
T = Worksheets("List").Cells(1, 1).Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
ClientName = ActiveCell.Offset(0, 1)
SendFile = ActiveCell.Offset(0, 2)
Email = ActiveCell.Offset(0, 5)
Password = ActiveCell.Offset(0, 8)
'*** Check installation of WinRar ***
WinRarPath = "C:\Program Files\WinRar\"
If Dir(WinRarPath, vbDirectory) = "" Then
MsgBox "WinRar is not installed in the default directory." _
& Chr$(13) & "Archiving of files will not be possible."
Exit Sub
End If
'*** Set the source details ***
Source = Filepath & "\" & SendFile
'If source name has one or more spaces surround it with ""
If InStr(1, Source, " ", vbTextCompare) <> 0 Then Source = Chr(34) & Source & Chr(34)
'*** Set the destination details
DestDir = "c:\Documents and settings\Desktop"
'check that it exists
If Dir(DestDir, vbDirectory) = "" Then MkDir DestDir
Dest = DestDir & "\" & ClientName
If InStr(1, Dest, " ", vbTextCompare) <> 0 Then Dest = Chr(34) & Dest & Chr(34)
'*** Do the Rarping *** the -ep switch allows the file to be zipped
' without the entire directory location without it
' these folders will be zipped.
RarIt = Shell(WinRarPath & "WinRar.exe a -ep -hp" & Password & " -ieml." & Email & " " & Dest & " " & Source, vbNormalFocus)
Loop
End Sub
Function OrdinalSuffix(ByVal Num As Long) As String
' This function formats the date with st, nd, rd or th after the day
Dim N As Long
Const cSfx = "stndrdthththththth" ' 2 char suffixes
N = Num Mod 100
If ((Abs(N) >= 10) And (Abs(N) <= 19)) _
Or ((Abs(N) Mod 10) = 0) Then
OrdinalSuffix = "th"
Else
OrdinalSuffix = Mid(cSfx, _
((Abs(N) Mod 10) * 2) - 1, 2)
End If
End Function
Basically, I have a list of client information that need sending out. I need to zip, password and attach a file to each recipient so I have created a simple loop that helps to locate the file, password the file, add the headings to the filename and send it out.
What i'm wondering, is it possible to add a message body to my e-mail using the switches in the shell function and add a signature saved in my outlook?
Thanks
Rich
p.s i'd like to remind you that the coding for the rar was not written, i'm not that clever but i wrote the rest.
Bookmarks