A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Open folder with vba code launches a new window



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 10th 07, 01:46 PM posted to microsoft.public.outlook.program_vba
LDMueller
external usenet poster
 
Posts: 53
Default Open folder with vba code launches a new window

I have Outlook 2003. Basically I have an email in my inbox and when I run
this macro, I want the email to be moved to the folder "Problem
Report\Laptop" and then open this folder. My code works fine, but it's the
last line
(e.g. objFolder.Display) that I don't like. I want to open the folder, but
not launch a new window. If I manually open different folders, new windows
don't open so I'm hoping to do the same with code. I'm limited to what I
know with VBA so this was the only code I could at least get working.

Here is my code:

' Opens folder Problem Report\Laptop
Dim objOlApp As Outlook.Application
Dim objRecipient As Outlook.Recipient

Set objOlApp = CreateObject("Outlook.Application")
Set objNS = objOlApp.GetNamespace("MAPI")
Set objRecipient = objNS.CreateRecipient("Problem Report")

Set objFolder = GetFolder("Mailbox - Problem Report\Laptop")
objFolder.Display 'Will launch new window

Any assistance would be greatly appreciated.

Thanks!
  #2  
Old May 10th 07, 02:29 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Open folder with vba code launches a new window

Use this statement instead:

Set objOLApp.ActiveExplorer.CurrentFolder = objFolder

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"LDMueller" wrote in message ...
I have Outlook 2003. Basically I have an email in my inbox and when I run
this macro, I want the email to be moved to the folder "Problem
Report\Laptop" and then open this folder. My code works fine, but it's the
last line
(e.g. objFolder.Display) that I don't like. I want to open the folder, but
not launch a new window. If I manually open different folders, new windows
don't open so I'm hoping to do the same with code. I'm limited to what I
know with VBA so this was the only code I could at least get working.

Here is my code:

' Opens folder Problem Report\Laptop
Dim objOlApp As Outlook.Application
Dim objRecipient As Outlook.Recipient

Set objOlApp = CreateObject("Outlook.Application")
Set objNS = objOlApp.GetNamespace("MAPI")
Set objRecipient = objNS.CreateRecipient("Problem Report")

Set objFolder = GetFolder("Mailbox - Problem Report\Laptop")
objFolder.Display 'Will launch new window

Any assistance would be greatly appreciated.

Thanks!

  #3  
Old May 10th 07, 02:56 PM posted to microsoft.public.outlook.program_vba
LDMueller
external usenet poster
 
Posts: 53
Default Open folder with vba code launches a new window

Perfect! Thank you so much Sue.

LDMueller

"Sue Mosher [MVP-Outlook]" wrote:

Use this statement instead:

Set objOLApp.ActiveExplorer.CurrentFolder = objFolder

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"LDMueller" wrote in message ...
I have Outlook 2003. Basically I have an email in my inbox and when I run
this macro, I want the email to be moved to the folder "Problem
Report\Laptop" and then open this folder. My code works fine, but it's the
last line
(e.g. objFolder.Display) that I don't like. I want to open the folder, but
not launch a new window. If I manually open different folders, new windows
don't open so I'm hoping to do the same with code. I'm limited to what I
know with VBA so this was the only code I could at least get working.

Here is my code:

' Opens folder Problem Report\Laptop
Dim objOlApp As Outlook.Application
Dim objRecipient As Outlook.Recipient

Set objOlApp = CreateObject("Outlook.Application")
Set objNS = objOlApp.GetNamespace("MAPI")
Set objRecipient = objNS.CreateRecipient("Problem Report")

Set objFolder = GetFolder("Mailbox - Problem Report\Laptop")
objFolder.Display 'Will launch new window

Any assistance would be greatly appreciated.

Thanks!


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimizing the Outlook Window in Code Robert Jones Outlook and VBA 1 November 25th 06 03:56 PM
Open Links in New Window varguda Outlook Express 3 October 4th 06 01:16 PM
New window doesn't open mo32a Outlook Express 4 September 30th 06 07:11 PM
open a new window for a new mail norm Outlook Express 1 September 12th 06 08:17 PM
Hyperlinks in emails open a folder window, not Internet Explorer Jerom Outlook Express 3 August 6th 06 05:20 PM


All times are GMT +1. The time now is 12:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.