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

Create Folders Along with ObjItem.Move ?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 13th 06, 06:29 PM posted to microsoft.public.outlook.program_vba
gamename
external usenet poster
 
Posts: 12
Default Create Folders Along with ObjItem.Move ?

Hi,

I have a script which replaces rules in OL2003. The way I have folders
defined is like this:

Dim xxx As MAPIFolder
Set my_xxx = Inbox.Folders.Item("xxx")

' ... then after much logic to determine if this is the correct email
....

objItem.Move my_xxx


Is there any way to:
1) Create a folder if it doesn't exit
2) Avoid the Dim/Set steps?


TIA
-T

Ads
  #2  
Old July 13th 06, 06:36 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create Folders Along with ObjItem.Move ?

1) Create a folder if it doesn't exit

On Error Resume Next
Set myFolder = Inbox.Folders("My Folder")
If myFolder Is Nothing Then
Set myFolder = Inbox.Folders.Add("My Folder")
End If

2) Avoid the Dim/Set steps?


Why would you want to avoid good programming practice?

--
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

"gamename" wrote in message ups.com...
Hi,

I have a script which replaces rules in OL2003. The way I have folders
defined is like this:

Dim xxx As MAPIFolder
Set my_xxx = Inbox.Folders.Item("xxx")

' ... then after much logic to determine if this is the correct email
...

objItem.Move my_xxx


Is there any way to:
1) Create a folder if it doesn't exit
2) Avoid the Dim/Set steps?


TIA
-T

  #3  
Old July 13th 06, 09:21 PM posted to microsoft.public.outlook.program_vba
gamename
external usenet poster
 
Posts: 12
Default Create Folders Along with ObjItem.Move ?

Sue Mosher [MVP-Outlook] wrote:
1) Create a folder if it doesn't exit


On Error Resume Next
Set myFolder = Inbox.Folders("My Folder")
If myFolder Is Nothing Then
Set myFolder = Inbox.Folders.Add("My Folder")
End If

2) Avoid the Dim/Set steps?


Why would you want to avoid good programming practice?


So, every single possible folder needs to be pre-defined in VB?



--
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

"gamename" wrote in message ups.com...
Hi,

I have a script which replaces rules in OL2003. The way I have folders
defined is like this:

Dim xxx As MAPIFolder
Set my_xxx = Inbox.Folders.Item("xxx")

' ... then after much logic to determine if this is the correct email
...

objItem.Move my_xxx


Is there any way to:
1) Create a folder if it doesn't exit
2) Avoid the Dim/Set steps?


TIA
-T


  #4  
Old July 13th 06, 09:53 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create Folders Along with ObjItem.Move ?

No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.

--
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

"gamename" wrote in message oups.com...
Sue Mosher [MVP-Outlook] wrote:
1) Create a folder if it doesn't exit


On Error Resume Next
Set myFolder = Inbox.Folders("My Folder")
If myFolder Is Nothing Then
Set myFolder = Inbox.Folders.Add("My Folder")
End If

2) Avoid the Dim/Set steps?


Why would you want to avoid good programming practice?


So, every single possible folder needs to be pre-defined in VB?

"gamename" wrote in message ups.com...
Hi,

I have a script which replaces rules in OL2003. The way I have folders
defined is like this:

Dim xxx As MAPIFolder
Set my_xxx = Inbox.Folders.Item("xxx")

' ... then after much logic to determine if this is the correct email
...

objItem.Move my_xxx


Is there any way to:
1) Create a folder if it doesn't exit
2) Avoid the Dim/Set steps?


TIA
-T


  #5  
Old July 14th 06, 05:06 PM posted to microsoft.public.outlook.program_vba
gamename
external usenet poster
 
Posts: 12
Default Create Folders Along with ObjItem.Move ?


Sue Mosher [MVP-Outlook] wrote:
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.


OK. Is there an example somewhere for reference?

Thanks,
-T

  #6  
Old July 14th 06, 07:10 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create Folders Along with ObjItem.Move ?

You already had it in your earlier code snippet that you posted.

--
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

"gamename" wrote in message oups.com...

Sue Mosher [MVP-Outlook] wrote:
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.


OK. Is there an example somewhere for reference?

Thanks,
-T

  #7  
Old July 21st 06, 10:52 PM posted to microsoft.public.outlook.program_vba
gamename
external usenet poster
 
Posts: 12
Default Create Folders Along with ObjItem.Move ?

So, you're saying the way I had it defined in the original question is
correct?

-T

Sue Mosher [MVP-Outlook] wrote:
You already had it in your earlier code snippet that you posted.

--
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

"gamename" wrote in message oups.com...

Sue Mosher [MVP-Outlook] wrote:
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.


OK. Is there an example somewhere for reference?

Thanks,
-T


  #8  
Old July 21st 06, 11:11 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create Folders Along with ObjItem.Move ?

Dim xxx As MAPIFolder

Set xxx = some expression to get the folder

' move items to xxx

Set xxx = some expression to get another folder

' move items to xxx

--
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

"gamename" wrote in message ups.com...
So, you're saying the way I had it defined in the original question is
correct?

-T

Sue Mosher [MVP-Outlook] wrote:
You already had it in your earlier code snippet that you posted.

--
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

"gamename" wrote in message oups.com...

Sue Mosher [MVP-Outlook] wrote:
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.

OK. Is there an example somewhere for reference?

Thanks,
-T


  #9  
Old July 24th 06, 06:21 PM posted to microsoft.public.outlook.program_vba
gamename
external usenet poster
 
Posts: 12
Default Create Folders Along with ObjItem.Move ?


Ah, ok. Now I see what you're saying.

Thanks,
-T
Sue Mosher [MVP-Outlook] wrote:
Dim xxx As MAPIFolder

Set xxx = some expression to get the folder

' move items to xxx

Set xxx = some expression to get another folder

' move items to xxx

--
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

"gamename" wrote in message ups.com...
So, you're saying the way I had it defined in the original question is
correct?

-T

Sue Mosher [MVP-Outlook] wrote:
You already had it in your earlier code snippet that you posted.

--
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

"gamename" wrote in message oups.com...

Sue Mosher [MVP-Outlook] wrote:
No, you can Dim an object variable and instantiate it to the folder you want to move that item to. Then you later reuse the variable to move the item to a different folder.

OK. Is there an example somewhere for reference?

Thanks,
-T



 




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
Move Personal Folders Up or Down Doug Recla Outlook - General Queries 2 May 27th 06 03:45 PM
move inbox & merge archive folders? ny_dancer Outlook - General Queries 1 April 22nd 06 12:37 AM
How to move folders to another drive Fred Outlook Express 6 April 19th 06 09:42 PM
Backup OE folders to move to new hard drive Walter Cohen Outlook Express 2 April 8th 06 03:59 PM
Cannot Move IMAP Emails From Inbox To Folders Anymore JC Outlook Express 1 March 31st 06 08:41 PM


All times are GMT +1. The time now is 02:43 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.