it is a good thing that you identified Lindsay as the author of the above script, which gives me a chance to comment on it while being in a better position. I guess I might re-use the whole concept in the future.
If having multiple instances of Outlook is a concern, this is caused by using "AppSwapWith" in the first line of the code which came in by looking at the script that you provided from the start. So where is the problem with it?
Rüdiger
_______________________________________
Dragon Professional 16 auf Windows 10 Pro und Windows 11 SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo) HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD
Sorry, Marius, you are right, but the fault was with Lindsay obviously. I think I will go back to wrapping my legs around my neck, and post back if and only if I can come up with a working solution.
Rüdiger
_______________________________________
Dragon Professional 16 auf Windows 10 Pro und Windows 11 SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo) HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD
So, das funktioniert jetzt aber wie von Marius gefordert, sofern Outlook bereits gestartet ist:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Sub Main
AppSwapWith("Outlook")
Dim myNamespace As Outlook.NameSpace Dim myExp As Outlook.Explorer
Set myNamespace = Application.GetNamespace("MAPI") Set myExp = Application.ActiveExplorer Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderSentMail)
Set myExp = Nothing Set myNamespace = Nothing
End Sub
_______________________________________
Dragon Professional 16 auf Windows 10 Pro und Windows 11 SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo) HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD
Dim myNamespace As Outlook.NameSpace Dim myExp As Outlook.Explorer
Set myNamespace = Application.GetNamespace("MAPI") Set myExp = Application.ActiveExplorer
Select Case ListVar1 Case "Eingang" Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderInbox) Case "Ausgang" Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderSentMail) Case "Kalender" Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderCalendar) End Select
Set myExp = Nothing Set myNamespace = Nothing
End Sub
_______________________________________
Dragon Professional 16 auf Windows 10 Pro und Windows 11 SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo) HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD
Toll, toll, toll, vielen Dank für die Erfüllung der "Forderungen" - ich bin begeistert!
Es klappt übrigens auch z. B. mit weiteren Case-Zeilen für die Ordner Entwürfe und Journal wie folgt (alles natürlich nur, wenn der Befehlsname entsprechende Listeneinträge enthält und die Outlook-Bibliothek der jeweiligen Version eingebunden ist).
Case "Entwürfe" Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderDrafts) Case "Journal" Set myExp.CurrentFolder = myNamespace.GetDefaultFolder(olFolderJournal)
Dankbare Grüße, Marius Raabe
Dragon NaturallySpeaking 11.5 Legal Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8 Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM