Sherrie
11-05-2011, 07:07 PM
Hi all, as you know, i have been posting questions for bits and pieces.
This is what I have ended up with so far. It is not complete, but I thought it better to get smaller chunks working before working on the next chunks.
Sub ElectronicFiling()
Call LoopInboxFolders
End Sub
Sub ProjYear()
Dim ns As Outlook.NameSpace
Dim myfolder As Outlook.Folder
Dim mysubfolder As Outlook.Folder
Dim strProjYear As String
Dim strProjYr As String
Set ns = Application.GetNamespace("MAPI")
Set myfolder = ns.GetDefaultFolder(olFolderInbox)
Set mysubfolder = myfolder.Folders
strProjYr = Left(mysubfolder.Name, 2)
strProjYear = "20" & strProjYr
End Sub
Sub CorrInOut()
Dim iItem As Long
Dim strAddress As String
Dim strCorr As String
With Outlook.ActiveExplorer.Selection
strAddress = .Item(iItem).SenderEmailAddress
If strAddress Like "*@gascoigneconsultants.com" Then
'Sender is internal therefore email is outgoing
strCorr = "Out"
Else
strCorr = "In"
End If
End With
End Sub
Sub SavePath()
Dim strSavePath As String
Call ProjYear
Call CorrInOut
strSavePath = "G:\" & strProjYear & "\Projects\" & mysubfolder.Name & "\Correspondence\" & strCorr
End Sub
Sub LoopInboxFolders()
Dim ns As Outlook.NameSpace
Dim myfolder As Outlook.Folder
Dim mysubfolder As Outlook.Folder
Set ns = Application.GetNamespace("MAPI")
'Get the default inboxfolder
Set myfolder = ns.GetDefaultFolder(olFolderInbox)
'Loop through each folder and display name of the folder
For Each mysubfolder In myfolder.Folders
Call SavePath
MsgBox mysubfolder.Name
MsgBox strSavePath
Next mysubfolder
End Sub
I have ensured that macros are enabled in Outlook 2007 however nothing happens when I run the main macro which is ElectronicFiling.
Can anyone please let me know what I've done wrong?
Thanks heaps!
Sherrie
This is what I have ended up with so far. It is not complete, but I thought it better to get smaller chunks working before working on the next chunks.
Sub ElectronicFiling()
Call LoopInboxFolders
End Sub
Sub ProjYear()
Dim ns As Outlook.NameSpace
Dim myfolder As Outlook.Folder
Dim mysubfolder As Outlook.Folder
Dim strProjYear As String
Dim strProjYr As String
Set ns = Application.GetNamespace("MAPI")
Set myfolder = ns.GetDefaultFolder(olFolderInbox)
Set mysubfolder = myfolder.Folders
strProjYr = Left(mysubfolder.Name, 2)
strProjYear = "20" & strProjYr
End Sub
Sub CorrInOut()
Dim iItem As Long
Dim strAddress As String
Dim strCorr As String
With Outlook.ActiveExplorer.Selection
strAddress = .Item(iItem).SenderEmailAddress
If strAddress Like "*@gascoigneconsultants.com" Then
'Sender is internal therefore email is outgoing
strCorr = "Out"
Else
strCorr = "In"
End If
End With
End Sub
Sub SavePath()
Dim strSavePath As String
Call ProjYear
Call CorrInOut
strSavePath = "G:\" & strProjYear & "\Projects\" & mysubfolder.Name & "\Correspondence\" & strCorr
End Sub
Sub LoopInboxFolders()
Dim ns As Outlook.NameSpace
Dim myfolder As Outlook.Folder
Dim mysubfolder As Outlook.Folder
Set ns = Application.GetNamespace("MAPI")
'Get the default inboxfolder
Set myfolder = ns.GetDefaultFolder(olFolderInbox)
'Loop through each folder and display name of the folder
For Each mysubfolder In myfolder.Folders
Call SavePath
MsgBox mysubfolder.Name
MsgBox strSavePath
Next mysubfolder
End Sub
I have ensured that macros are enabled in Outlook 2007 however nothing happens when I run the main macro which is ElectronicFiling.
Can anyone please let me know what I've done wrong?
Thanks heaps!
Sherrie