I am "familiar" with creating (and recording) macro's in Excel, but don't really know a lot about how to get the most out of Outlook (2007). This time of year, we get a lot of emails generated from a webform on our website and we are then required to create folders on our server for each email and save the email to. I was hoping there might be some way to automate at least some of this process, but Outlook is really unfamiliar to me and without a recorder function to at least help reverse engineer certain actions... I'm just not sure where to start.
I made a macro (with help from the excel forums) to create folders based on values in an excel spreadsheet, which is similar in concept to what I'd like to do in outlook. In this macro, each cell value looked something like "22-265-02349856". The macro would then prompt the user for the root folder location and then loop through all the cells in the range and create the folder structure with folder levels Folder level 1: "22" -> subfolder "265" -> subfolder "02349856"
I'm hoping to be able to do something similar in outlook. I think the best possible option would be to select the values (from 3 cells) from a table in the message body (the result of the webform submission), which form the basis for the folder path I'd like to create. So like the excel example above, the table in the body of my outlook message would have 3 cells, each containing one of the values 22, 265, and 02349856. Is there a way to select these 3 cells and then run a macro via hotkey that would create the folders and subfolders (unless they already exist) for each of 22 -> 265 -> 02349856 and then save a copy of the message in the last folder 02349856?
This is my excel macro, I feel like if I just knew how to reference the table from the message body, I could probably figure out at least a viable attempt at how to modify it... assuming of course MkDir works as well in Outlook as it does in Excel... Basically I would like to remove the loop and replace the
with something that acts like FileRef = "Selected cells from table where
Does that make sense? Here's the Excel code...
Any assistance or advice would be very much appreciated
Thanks,
Joe
I made a macro (with help from the excel forums) to create folders based on values in an excel spreadsheet, which is similar in concept to what I'd like to do in outlook. In this macro, each cell value looked something like "22-265-02349856". The macro would then prompt the user for the root folder location and then loop through all the cells in the range and create the folder structure with folder levels Folder level 1: "22" -> subfolder "265" -> subfolder "02349856"
I'm hoping to be able to do something similar in outlook. I think the best possible option would be to select the values (from 3 cells) from a table in the message body (the result of the webform submission), which form the basis for the folder path I'd like to create. So like the excel example above, the table in the body of my outlook message would have 3 cells, each containing one of the values 22, 265, and 02349856. Is there a way to select these 3 cells and then run a macro via hotkey that would create the folders and subfolders (unless they already exist) for each of 22 -> 265 -> 02349856 and then save a copy of the message in the last folder 02349856?
This is my excel macro, I feel like if I just knew how to reference the table from the message body, I could probably figure out at least a viable attempt at how to modify it... assuming of course MkDir works as well in Outlook as it does in Excel... Basically I would like to remove the loop and replace the
Code:
FileRef = ActiveSheet.Range("A" & i).Text
Code:
FldrLvl1 = "First or top Cell"
FldrLvl2 = "Second or Middle Cell"
FldrLvl3 = "Third or Bottom Cell"
Does that make sense? Here's the Excel code...
Code:
Option Explicit
Sub CreateFileFolders()
Dim LastRow As Long, i As Long, n As Long
Dim FldrRoot As String, FldrLvl1 As String, FldrLvl2 As String, FldrLvl3 As String, FileRef As String
Dim xDirectFldrRoot$, InitialFoldr$
InitialFoldr$ = "H:\"
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select the parent folder; subfolders will be created. "
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count <> 0 Then
xDirectFldrRoot$ = .SelectedItems(1) & "\"
Else
End If
End With
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
FldrRoot = xDirectFldrRoot$
If Cells(1, 1).Value Like "*201*" Then i = 1 Else: i = 2
For i = i To LastRow
FileRef = ActiveSheet.Range("A" & i).Text '//FileRef is ##-###-########...\\
FldrLvl1 = Left(FileRef, 2) '//Extract first 2 characters from sting\\
FldrLvl2 = Mid(FileRef, 4, 3) '//Extract middle 3\\
FldrLvl3 = Right(FileRef, 8) '//Extract last 8\\
On Error Resume Next '//if folder exists - igonore error and carry on\\
MkDir (FldrRoot & "\" & FldrLvl1) '//Create Level 1 folder (eg; 22)\\
MkDir (FldrRoot & "\" & FldrLvl1 & "\" & FldrLvl2) '//Create Level 2 folder (eg; 265)\\
MkDir (FldrRoot & "\" & FldrLvl1 & "\" & FldrLvl2 & "\" & FldrLvl3) '//Create Level 3 folder (eg; 02349856)\\
On Error GoTo 0 '//resume errors\\
Next
End Sub
Any assistance or advice would be very much appreciated
Thanks,
Joe