change folder and back

Status
Not open for further replies.

framednlv

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
How can I save the current folder, change to sent items folder, do some stuff (from userform) and then change back to the original folder when done?

Thanks,
Chris
 

framednlv

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
This is what I have so far:
Code:
Sub ChangeCurrentFolder()
    Dim myolApp As Outlook.Application
    Dim myNamespace As Outlook.NameSpace
   
    Set myolApp = CreateObject("Outlook.Application")
    Set myNamespace = myolApp.GetNamespace("MAPI")
    Set myolApp.ActiveExplorer.CurrentFolder = myNamespace.GetDefaultFolder(olFolderSentMail)
    Application.ActiveExplorer.ClearSelection
    Application.ActiveExplorer.Activate
    MsgBox "First select email from Sent Items to save"
    UserForm1.Show
   
    'need to return to original folder after UserForm1
End Sub
How can I save the current folder before changing to the sent items folder? How do I get back to the original folder after the UserForm1 is finished?
 

framednlv

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
Ok, I hacked pieces and part and came up with this:

Code:
Sub SentSave()
Dim objOL As Object 'As Outlook.Application
Dim objFolder As Object 'As Outlook.Folder
    'get current folder
    Set objOL = CreateObject("Outlook.Application")
    Set objFolder = objOL.ActiveExplorer.CurrentFolder
    Set objOL.ActiveExplorer.CurrentFolder = objFolder
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myOlApp.ActiveExplorer.CurrentFolder = myNamespace.GetDefaultFolder(olFolderSentMail)
    Application.ActiveExplorer.ClearSelection
    Application.ActiveExplorer.Activate
   
    'save emails to job folders using listbox
    UserForm1.Show

    'return to original folder
    Set objOL.ActiveExplorer.CurrentFolder = objFolder


ExitSub:

Set objOL = Nothing
Set objFolder = Nothing

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
R Folder pane width change Using Outlook 69
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
Kika Melo Change location of Outlook SecureTemporary Files Folder Using Outlook 5
Z Batch Change Folder Views in Outlook 2016 Using Outlook 1
J Outlook 2007 - Change Message Class for all Items in Folder Outlook VBA and Custom Forms 1
David Rahrer Change default Junk E-Mail folder Using Outlook 6
C Change the default sent folder Outlook VBA and Custom Forms 1
P Last Change attribute set after viewing a public folder contact Exchange Server Administration 0
C Macro to change folder of rules automatically Outlook VBA and Custom Forms 7
O Change folder doesn't work Using Outlook 2
J How To Change Font Size For Folder Names on Navigation Pane in Outlook 2013 Using Outlook 1
H how to change the Folder icon in Contact Using Outlook 7
C How do I change the default "Add to Outlook Contacts" Folder Using Outlook 6
B Macro to Change sort and collapse groups in Mail folder Outlook VBA and Custom Forms 9
M Can't change autoarchive property in Deleted Items folder BCM (Business Contact Manager) 1
S Change "This Week" flag start date behavior Using Outlook 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1

Similar threads

Top