Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / October 2005

Tip: Looking for answers? Try searching our database.

Question Of my code, and General Question...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ruben - 30 Oct 2005 06:34 GMT
Hi!, here is my code, that i wirte just to move the item from some folders to
one folder specified.
When i run it, its work, but with the progress bar i just see in my form the
progree bar component that work, but the another components (label, and
button) i cannot see before its finish to move all the items.

Someone can tell me wath wrong in my Vba form???

Another question, es the Rules. I see in this forum, that cannot run rules
from code VBA. As i ask, is any way to do that without the user???? Because,
when i move all the item to the folder, i need to run the Rules. (and because
of that i move first the items, to do "Run Rules Now". But if i can do run
the rules automaticaly, i dont need to move the items.

Thanks a lot.
Ruben

Private Sub btnClose_Click()
   Me.Hide
End Sub

Private Sub UserForm_Activate()
   Call MoveElItems
End Sub

Private Sub MoveElistasItems()

   Dim objNS As Outlook.NameSpace
   Dim objInbox As Outlook.MAPIFolder
   Dim objEls As Outlook.MAPIFolder
   Dim ElEmail As Outlook.MailItem
   
   On Error Resume Next

   Set objNS = Application.GetNamespace("MAPI")
   Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
   Set m_DNSBlackListItems = objInbox.Folders.Item("DNSBlackList").Items
   Set m_BayesianItems = objInbox.Folders.Item("Bayesian").Items
   Set m_HeaderItems = objInbox.Folders.Item("Header").Items
   Set m_KeywordItems = objInbox.Folders.Item("Keyword").Items
   
   Set objEl = objInbox.Folders.Item("El.net")
   Dim totalitems As Integer
   totalitems = m_DNSBlackListItems.Count + m_BayesianItems.Count +
m_HeaderItems.Count + m_KeywordItems.Count

   totalProcess = 0
   
   PBarItems.Value = 0
   PBarItems.Max = totalitems
   PBarItems.Min = 0
   
   For i = m_DNSBlackListItems.Count To 1 Step -1
       Set ElistasEmail = m_DNSBlackListItems.Item(i)
       ElEmail.Move objEl
       totalProcess = totalProcess + 1
       CountOfItems.Caption = ElEmail.Subject
       PBarItems.Value = totalProcess
   Next
   Set ElEmail = Nothing

   For i = m_BayesianItems.Count To 1 Step -1
      Set ElEmail = m_BayesianItems.Item(i)
      ElEmail.Move objEl
      totalProcess = totalProcess + 1
      PBarItems.Value = totalProcess
   Next
   Set ElEmail = Nothing
   
   For i = m_HeaderItems.Count To 1 Step -1
       Set ElEmail = m_HeaderItems.Item(i)
       ElEmail.Move objEl
       totalProcess = totalProcess + 1
      PBarItems.Value = totalProcess
   Next
   Set ElEmail = Nothing
   
   For i = m_KeywordItems.Count To 1 Step -1
       Set ElEmail = m_KeywordItems.Item(i)
       ElEmail.Move objEl
       totalProcess = totalProcess + 1
       PBarItems.Value = totalProcess
   Next
   Set ElEmail = Nothing
   btnClose.Enabled = True
End Sub
Michael Bauer - 30 Oct 2005 09:55 GMT
Am Sat, 29 Oct 2005 23:34:04 -0700 schrieb Ruben:

Ruben, just call DoEvents from within the loops. That interrupts the loop
for a very short time and gives the process the ability to do other waiting
tasks - like updating controls.

The answer to your seconds question is yes. You can´t run a rule
programmatically but you can solve it without the user: Just replace all the
rules by your own VBA code.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Hi!, here is my code, that i wirte just to move the item from some folders to
> one folder specified.
[quoted text clipped - 82 lines]
>     btnClose.Enabled = True
> End Sub
Ruben - 30 Oct 2005 11:01 GMT
Thanks A  Lot.
Its Work Excelent!...

Ruben

> Am Sat, 29 Oct 2005 23:34:04 -0700 schrieb Ruben:
>
[quoted text clipped - 96 lines]
> >     btnClose.Enabled = True
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.