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

Help - VB Macro no longer work



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 23rd 10, 06:14 PM posted to microsoft.public.outlook.program_vba
mobamoba
external usenet poster
 
Posts: 7
Default Help - VB Macro no longer work

I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. I rebooted today,
restarted Outlook and the macro is no longer working. Nothing in my
setup has changed at all. When I go to the VB Editor, the error I'm
getting is "Object not found." Considering I've changed absolutely
nothing, what, suddenly, isn't being found? I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Thanks
in advance for any help because this problem is making me nuts!

Sub MoveMessage()

Dim onsMapi As Outlook.NameSpace
Dim oexpSource As Outlook.Explorer
Dim objItem As Object
Dim omapiDestination As Outlook.MAPIFolder
Dim lCount As Long


' Find the destination Folder 'Saved Mail'
Set onsMapi = Application.GetNamespace("MAPI")
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
' Get the current explorer
Set oexpSource = Application.ActiveExplorer
' Check each selection
For Each objItem In oexpSource.Selection
If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
' Move selection
objItem.Move omapiDestination
End If
Next

' Clean up
Set omapiDestination = Nothing
Set oexpSource = Nothing
Set onsMapi = Nothing
Set objItem = Nothing

End Sub

Ads
  #2  
Old February 24th 10, 08:13 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Help - VB Macro no longer work



At which row do you get the error?

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
http://www.vboffice.net/product.html?pub=6&lang=en


Am Tue, 23 Feb 2010 10:14:18 -0800 (PST) schrieb mobamoba:

I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. I rebooted today,
restarted Outlook and the macro is no longer working. Nothing in my
setup has changed at all. When I go to the VB Editor, the error I'm
getting is "Object not found." Considering I've changed absolutely
nothing, what, suddenly, isn't being found? I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Thanks
in advance for any help because this problem is making me nuts!

Sub MoveMessage()

Dim onsMapi As Outlook.NameSpace
Dim oexpSource As Outlook.Explorer
Dim objItem As Object
Dim omapiDestination As Outlook.MAPIFolder
Dim lCount As Long


' Find the destination Folder 'Saved Mail'
Set onsMapi = Application.GetNamespace("MAPI")
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
' Get the current explorer
Set oexpSource = Application.ActiveExplorer
' Check each selection
For Each objItem In oexpSource.Selection
If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
' Move selection
objItem.Move omapiDestination
End If
Next

' Clean up
Set omapiDestination = Nothing
Set oexpSource = Nothing
Set onsMapi = Nothing
Set objItem = Nothing

End Sub

  #3  
Old February 24th 10, 08:52 PM posted to microsoft.public.outlook.program_vba
mobamoba
external usenet poster
 
Posts: 7
Default Help - VB Macro no longer work

The line that references the "Saved Mail" folder is the one that's
screwing up:
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved Mail")

Basically, it can't find that folder even though it exists.

I created a new Saved Mail folder as a subfolder of the Inbox and was
able to get it to work using this:
Dim myInbox As Outlook.MAPIFolder
Set myInbox = onsMapi.GetDefaultFolder(olFolderInbox)
Set omapiDestination = myInbox.Folders("Saved Mail")

However, that wasn't really a solution. I don't want a subfolder to
my Inbox; I want Saved Mail as its own folder - and I can't figure out
how to make the macro find it. Any thoughts? Thanks!

On Feb 24, 3:13Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
At which row do you get the error?

--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en

Am Tue, 23 Feb 2010 10:14:18 -0800 (PST) schrieb mobamoba:

I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. Â*I rebooted today,
restarted Outlook and the macro is no longer working. Â*Nothing in my
setup has changed at all. Â*When I go to the VB Editor, the error I'm
getting is "Object not found." Â*Considering I've changed absolutely
nothing, what, suddenly, isn't being found? Â*I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Â*Thanks
in advance for any help because this problem is making me nuts!


Sub MoveMessage()


Â* Dim onsMapi As Outlook.NameSpace
Â* Dim oexpSource As Outlook.Explorer
Â* Dim objItem As Object
Â* Dim omapiDestination As Outlook.MAPIFolder
Â* Dim lCount As Long


Â* ' Find the destination Folder 'Saved Mail'
Â* Set onsMapi = Application.GetNamespace("MAPI")
Â* Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
Â* ' Get the current explorer
Â* Set oexpSource = Application.ActiveExplorer
Â* ' Check each selection
Â* For Each objItem In oexpSource.Selection
Â* Â* If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
Â* Â* Â* ' Move selection
Â* Â* Â* objItem.Move omapiDestination
Â* Â* End If
Â* Next


Â* ' Clean up
Â* Set omapiDestination = Nothing
Â* Set oexpSource = Nothing
Â* Set onsMapi = Nothing
Â* Set objItem = Nothing


End Sub


  #4  
Old February 25th 10, 09:23 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Help - VB Macro no longer work



The error is quite clear: the folder doesn't exist.

Check what GetFirst returns, and see if that's really what you expect it to
be.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
http://www.vboffice.net/product.html?pub=6&lang=en


Am Wed, 24 Feb 2010 12:52:55 -0800 (PST) schrieb mobamoba:

The line that references the "Saved Mail" folder is the one that's
screwing up:
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved Mail")

Basically, it can't find that folder even though it exists.

I created a new Saved Mail folder as a subfolder of the Inbox and was
able to get it to work using this:
Dim myInbox As Outlook.MAPIFolder
Set myInbox = onsMapi.GetDefaultFolder(olFolderInbox)
Set omapiDestination = myInbox.Folders("Saved Mail")

However, that wasn't really a solution. I don't want a subfolder to
my Inbox; I want Saved Mail as its own folder - and I can't figure out
how to make the macro find it. Any thoughts? Thanks!

On Feb 24, 3:13Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
At which row do you get the error?

--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en

Am Tue, 23 Feb 2010 10:14:18 -0800 (PST) schrieb mobamoba:

I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. Â*I rebooted today,
restarted Outlook and the macro is no longer working. Â*Nothing in my
setup has changed at all. Â*When I go to the VB Editor, the error I'm
getting is "Object not found." Â*Considering I've changed absolutely
nothing, what, suddenly, isn't being found? Â*I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Â*Thanks
in advance for any help because this problem is making me nuts!


Sub MoveMessage()


Â* Dim onsMapi As Outlook.NameSpace
Â* Dim oexpSource As Outlook.Explorer
Â* Dim objItem As Object
Â* Dim omapiDestination As Outlook.MAPIFolder
Â* Dim lCount As Long


Â* ' Find the destination Folder 'Saved Mail'
Â* Set onsMapi = Application.GetNamespace("MAPI")
Â* Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
Â* ' Get the current explorer
Â* Set oexpSource = Application.ActiveExplorer
Â* ' Check each selection
Â* For Each objItem In oexpSource.Selection
Â* Â* If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
Â* Â* Â* ' Move selection
Â* Â* Â* objItem.Move omapiDestination
Â* Â* End If
Â* Next


Â* ' Clean up
Â* Set omapiDestination = Nothing
Â* Set oexpSource = Nothing
Â* Set onsMapi = Nothing
Â* Set objItem = Nothing


End Sub

  #5  
Old February 25th 10, 03:37 PM posted to microsoft.public.outlook.program_vba
mobamoba
external usenet poster
 
Posts: 7
Default Help - VB Macro no longer work

The folder exists. I'm staring at it. I'm a VB beginner - how do I
find out what GetFirst is returning?

On Feb 25, 4:23Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
The error is quite clear: the folder doesn't exist.

Check what GetFirst returns, and see if that's really what you expect it to
be.

--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en

Am Wed, 24 Feb 2010 12:52:55 -0800 (PST) schrieb mobamoba:

The line that references the "Saved Mail" folder is the one that's
screwing up:
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved Mail")


Basically, it can't find that folder even though it exists.


I created a new Saved Mail folder as a subfolder of the Inbox and was
able to get it to work using this:
Dim myInbox As Outlook.MAPIFolder
Set myInbox = onsMapi.GetDefaultFolder(olFolderInbox)
Â*Set omapiDestination = myInbox.Folders("Saved Mail")


However, that wasn't really a solution. Â*I don't want a subfolder to
my Inbox; I want Saved Mail as its own folder - and I can't figure out
how to make the macro find it. Â*Any thoughts? Â*Thanks!


On Feb 24, 3:13Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
At which row do you get the error?


--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en


Am Tue, 23 Feb 2010 10:14:18 -0800 (PST) schrieb mobamoba:


I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. Â*I rebooted today,
restarted Outlook and the macro is no longer working. Â*Nothing in my
setup has changed at all. Â*When I go to the VB Editor, the error I'm
getting is "Object not found." Â*Considering I've changed absolutely
nothing, what, suddenly, isn't being found? Â*I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Â*Thanks
in advance for any help because this problem is making me nuts!


Sub MoveMessage()


Â* Dim onsMapi As Outlook.NameSpace
Â* Dim oexpSource As Outlook.Explorer
Â* Dim objItem As Object
Â* Dim omapiDestination As Outlook.MAPIFolder
Â* Dim lCount As Long


Â* ' Find the destination Folder 'Saved Mail'
Â* Set onsMapi = Application.GetNamespace("MAPI")
Â* Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
Â* ' Get the current explorer
Â* Set oexpSource = Application.ActiveExplorer
Â* ' Check each selection
Â* For Each objItem In oexpSource.Selection
Â* Â* If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
Â* Â* Â* ' Move selection
Â* Â* Â* objItem.Move omapiDestination
Â* Â* End If
Â* Next


Â* ' Clean up
Â* Set omapiDestination = Nothing
Â* Set oexpSource = Nothing
Â* Set onsMapi = Nothing
Â* Set objItem = Nothing


End Sub


  #6  
Old February 25th 10, 04:13 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Help - VB Macro no longer work



Use more variables, then you can work with the properties of an object. For
instance:

Dim F as MapiFolder
Set F=onsMapi.Folders.GetFirst
Msgbox F.FolderPath

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 25 Feb 2010 07:37:20 -0800 (PST) schrieb mobamoba:

The folder exists. I'm staring at it. I'm a VB beginner - how do I
find out what GetFirst is returning?

On Feb 25, 4:23Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
The error is quite clear: the folder doesn't exist.

Check what GetFirst returns, and see if that's really what you expect it

to
be.

--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en

Am Wed, 24 Feb 2010 12:52:55 -0800 (PST) schrieb mobamoba:

The line that references the "Saved Mail" folder is the one that's
screwing up:
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved Mail")


Basically, it can't find that folder even though it exists.


I created a new Saved Mail folder as a subfolder of the Inbox and was
able to get it to work using this:
Dim myInbox As Outlook.MAPIFolder
Set myInbox = onsMapi.GetDefaultFolder(olFolderInbox)
Â*Set omapiDestination = myInbox.Folders("Saved Mail")


However, that wasn't really a solution. Â*I don't want a subfolder to
my Inbox; I want Saved Mail as its own folder - and I can't figure out
how to make the macro find it. Â*Any thoughts? Â*Thanks!


On Feb 24, 3:13Â*am, "Michael Bauer [MVP - Outlook]"
wrote:
At which row do you get the error?


--
Best regards
Michael Bauer - MVP Outlook
Â* Manage and share your categories:
Â* http://www.vboffice.net/product.html?pub=6〈=en


Am Tue, 23 Feb 2010 10:14:18 -0800 (PST) schrieb mobamoba:


I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. Â*I rebooted today,
restarted Outlook and the macro is no longer working. Â*Nothing in my
setup has changed at all. Â*When I go to the VB Editor, the error I'm
getting is "Object not found." Â*Considering I've changed absolutely
nothing, what, suddenly, isn't being found? Â*I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Â*Thanks
in advance for any help because this problem is making me nuts!


Sub MoveMessage()


Â* Dim onsMapi As Outlook.NameSpace
Â* Dim oexpSource As Outlook.Explorer
Â* Dim objItem As Object
Â* Dim omapiDestination As Outlook.MAPIFolder
Â* Dim lCount As Long


Â* ' Find the destination Folder 'Saved Mail'
Â* Set onsMapi = Application.GetNamespace("MAPI")
Â* Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
Â* ' Get the current explorer
Â* Set oexpSource = Application.ActiveExplorer
Â* ' Check each selection
Â* For Each objItem In oexpSource.Selection
Â* Â* If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
Â* Â* Â* ' Move selection
Â* Â* Â* objItem.Move omapiDestination
Â* Â* End If
Â* Next


Â* ' Clean up
Â* Set omapiDestination = Nothing
Â* Set oexpSource = Nothing
Â* Set onsMapi = Nothing
Â* Set objItem = Nothing


End Sub

 




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
Views no longer work properly Mortimer Schnerd, RN Outlook Express 13 December 14th 08 07:29 PM
'Work Offline' no longer prompting for credentials No Name Outlook - General Queries 0 January 26th 08 05:25 PM
Macro to populate contact fields no longer working RitaP Outlook and VBA 2 February 27th 07 06:45 PM
Hyperlinks in email no longer work... Brian Tillman Outlook - General Queries 1 May 11th 06 12:23 AM
links no longer work in OE? Jon Patrick Outlook Express 4 April 28th 06 04:20 AM


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