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

VBA Disapperas



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 23rd 06, 11:41 PM posted to microsoft.public.outlook.program_vba
Nick_NZ
external usenet poster
 
Posts: 9
Default VBA Disapperas

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some reason
it disappears causing the subsequent rule to fail. It usually runs around 10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.

Ads
  #2  
Old November 24th 06, 06:18 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default VBA Disapperas



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some

reason
it disappears causing the subsequent rule to fail. It usually runs around

10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.

  #3  
Old November 26th 06, 08:18 PM posted to microsoft.public.outlook.program_vba
Nick_NZ
external usenet poster
 
Posts: 9
Default VBA Disapperas

Hi,

The rule fails and a message appears that outlook can not locate the code.
When I go into the VB editor the code is not there at all. This problem is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some

reason
it disappears causing the subsequent rule to fail. It usually runs around

10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.


  #4  
Old November 27th 06, 06:17 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default VBA Disapperas


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Sun, 26 Nov 2006 12:18:01 -0800 schrieb Nick_NZ:

Hi,

The rule fails and a message appears that outlook can not locate the code.
When I go into the VB editor the code is not there at all. This problem is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some

reason
it disappears causing the subsequent rule to fail. It usually runs

around
10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.


  #5  
Old November 27th 06, 07:35 PM posted to microsoft.public.outlook.program_vba
Nick_NZ
external usenet poster
 
Posts: 9
Default VBA Disapperas

Hi,

There is nothing in the disbaled items list. I can't find a deactivated
items, am I looking in the right place? Can you guys think of anything else,
I have been trying to solve this issue for about 2 months now!


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.


"Michael Bauer [MVP - Outlook]" wrote:


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Sun, 26 Nov 2006 12:18:01 -0800 schrieb Nick_NZ:

Hi,

The rule fails and a message appears that outlook can not locate the code.
When I go into the VB editor the code is not there at all. This problem is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some
reason
it disappears causing the subsequent rule to fail. It usually runs

around
10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.


  #6  
Old November 28th 06, 05:51 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default VBA Disapperas



Could you please show the code?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Mon, 27 Nov 2006 11:35:01 -0800 schrieb Nick_NZ:

Hi,

There is nothing in the disbaled items list. I can't find a deactivated
items, am I looking in the right place? Can you guys think of anything

else,
I have been trying to solve this issue for about 2 months now!


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.


"Michael Bauer [MVP - Outlook]" wrote:


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Sun, 26 Nov 2006 12:18:01 -0800 schrieb Nick_NZ:

Hi,

The rule fails and a message appears that outlook can not locate the

code.
When I go into the VB editor the code is not there at all. This problem

is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some
reason
it disappears causing the subsequent rule to fail. It usually runs

around
10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.


  #7  
Old November 28th 06, 07:08 PM posted to microsoft.public.outlook.program_vba
Nick_NZ
external usenet poster
 
Posts: 9
Default VBA Disapperas

Here it is:

Sub MakeTaskFromMail(olMail As Outlook.MailItem)
Dim objTask As Outlook.TaskItem

Set objTask = Application.CreateItem(olTaskItem)
With objTask
.Subject = olMail.Subject
.DueDate = DateAddW(olMail.SentOn, 5)
.ReminderTime = DateAddW(olMail.SentOn, 4)
.Importance = olImportanceHigh
.Body = olMail.Body
End With

Call CopyAttachments(olMail, objTask)

olMail.Delete

objTask.Save

Set objTask = Nothing

End Sub

Sub CopyAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next

Set fldTemp = Nothing
Set fso = Nothing
End Sub

'================================================= ================================================== ======'
'The follwoing code was obtained from:
http://support.microsoft.com/default...en-us%3B198505 '
'================================================= ================================================== ======'

'================================================= ======='
' The DateAddW() function provides a workday substitute '
' for DateAdd("w", number, date). This function performs '
' error checking and ignores fractional Interval values. '
'================================================= ======='
Function DateAddW(ByVal TheDate, ByVal Interval)

Dim Weeks As Long, OddDays As Long, Temp As String

If VarType(TheDate) 7 Or VarType(Interval) 2 Or _
VarType(Interval) 5 Then
DateAddW = TheDate
ElseIf Interval = 0 Then
DateAddW = TheDate
ElseIf Interval 0 Then
Interval = Int(Interval)

' Make sure TheDate is a workday (round down).

Temp = Format(TheDate, "ddd")
If Temp = "Sun" Then
TheDate = TheDate - 2
ElseIf Temp = "Sat" Then
TheDate = TheDate - 1
End If

' Calculate Weeks and OddDays.

Weeks = Int(Interval / 5)
OddDays = Interval - (Weeks * 5)
TheDate = TheDate + (Weeks * 7)

' Take OddDays weekend into account.

If (DatePart("w", TheDate) + OddDays) 6 Then
TheDate = TheDate + OddDays + 2
Else
TheDate = TheDate + OddDays
End If

DateAddW = TheDate
Else ' Interval is 0
Interval = Int(-Interval) ' Make positive & subtract later.

' Make sure TheDate is a workday (round up).

Temp = Format(TheDate, "ddd")
If Temp = "Sun" Then
TheDate = TheDate + 1
ElseIf Temp = "Sat" Then
TheDate = TheDate + 2
End If

' Calculate Weeks and OddDays.

Weeks = Int(Interval / 5)
OddDays = Interval - (Weeks * 5)
TheDate = TheDate - (Weeks * 7)

' Take OddDays weekend into account.

If (DatePart("w", TheDate) - OddDays) 2 Then
TheDate = TheDate - OddDays - 2
Else
TheDate = TheDate - OddDays
End If

DateAddW = TheDate
End If

End Function



'Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)End Sub'


Cheers,
Nick

"Michael Bauer [MVP - Outlook]" wrote:



Could you please show the code?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Mon, 27 Nov 2006 11:35:01 -0800 schrieb Nick_NZ:

Hi,

There is nothing in the disbaled items list. I can't find a deactivated
items, am I looking in the right place? Can you guys think of anything

else,
I have been trying to solve this issue for about 2 months now!


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.


"Michael Bauer [MVP - Outlook]" wrote:


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Sun, 26 Nov 2006 12:18:01 -0800 schrieb Nick_NZ:

Hi,

The rule fails and a message appears that outlook can not locate the

code.
When I go into the VB editor the code is not there at all. This problem

is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some
reason
it disappears causing the subsequent rule to fail. It usually runs
around
10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be greatly
appreciated.



  #8  
Old November 29th 06, 06:41 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default VBA Disapperas


Frankly, I don't know what's going on. Maybe Outlook (sometimes) doesn't
like that you delete olMail within the rule?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Tue, 28 Nov 2006 11:08:01 -0800 schrieb Nick_NZ:

Here it is:

Sub MakeTaskFromMail(olMail As Outlook.MailItem)
Dim objTask As Outlook.TaskItem

Set objTask = Application.CreateItem(olTaskItem)
With objTask
.Subject = olMail.Subject
.DueDate = DateAddW(olMail.SentOn, 5)
.ReminderTime = DateAddW(olMail.SentOn, 4)
.Importance = olImportanceHigh
.Body = olMail.Body
End With

Call CopyAttachments(olMail, objTask)

olMail.Delete

objTask.Save

Set objTask = Nothing

End Sub

Sub CopyAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next

Set fldTemp = Nothing
Set fso = Nothing
End Sub


'================================================= ================================================== ======'
'The follwoing code was obtained from:
http://support.microsoft.com/default...en-us%3B198505 '

'================================================= ================================================== ======'

'================================================= ======='
' The DateAddW() function provides a workday substitute '
' for DateAdd("w", number, date). This function performs '
' error checking and ignores fractional Interval values. '
'================================================= ======='
Function DateAddW(ByVal TheDate, ByVal Interval)

Dim Weeks As Long, OddDays As Long, Temp As String

If VarType(TheDate) 7 Or VarType(Interval) 2 Or _
VarType(Interval) 5 Then
DateAddW = TheDate
ElseIf Interval = 0 Then
DateAddW = TheDate
ElseIf Interval 0 Then
Interval = Int(Interval)

' Make sure TheDate is a workday (round down).

Temp = Format(TheDate, "ddd")
If Temp = "Sun" Then
TheDate = TheDate - 2
ElseIf Temp = "Sat" Then
TheDate = TheDate - 1
End If

' Calculate Weeks and OddDays.

Weeks = Int(Interval / 5)
OddDays = Interval - (Weeks * 5)
TheDate = TheDate + (Weeks * 7)

' Take OddDays weekend into account.

If (DatePart("w", TheDate) + OddDays) 6 Then
TheDate = TheDate + OddDays + 2
Else
TheDate = TheDate + OddDays
End If

DateAddW = TheDate
Else ' Interval is 0
Interval = Int(-Interval) ' Make positive & subtract later.

' Make sure TheDate is a workday (round up).

Temp = Format(TheDate, "ddd")
If Temp = "Sun" Then
TheDate = TheDate + 1
ElseIf Temp = "Sat" Then
TheDate = TheDate + 2
End If

' Calculate Weeks and OddDays.

Weeks = Int(Interval / 5)
OddDays = Interval - (Weeks * 5)
TheDate = TheDate - (Weeks * 7)

' Take OddDays weekend into account.

If (DatePart("w", TheDate) - OddDays) 2 Then
TheDate = TheDate - OddDays - 2
Else
TheDate = TheDate - OddDays
End If

DateAddW = TheDate
End If

End Function



'Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)End Sub'


Cheers,
Nick

"Michael Bauer [MVP - Outlook]" wrote:



Could you please show the code?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Mon, 27 Nov 2006 11:35:01 -0800 schrieb Nick_NZ:

Hi,

There is nothing in the disbaled items list. I can't find a deactivated
items, am I looking in the right place? Can you guys think of anything

else,
I have been trying to solve this issue for about 2 months now!


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.


"Michael Bauer [MVP - Outlook]" wrote:


Can you enable VBA again via Help/About/Deactivated Items? Often that's
caused by VBA code that tries to instantiate a new Outlook Application
object, e.g. by CreateObject.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Am Sun, 26 Nov 2006 12:18:01 -0800 schrieb Nick_NZ:

Hi,

The rule fails and a message appears that outlook can not locate the

code.
When I go into the VB editor the code is not there at all. This

problem
is
very weird as the code will just not be there for no apparent reason.

"Michael Bauer [MVP - Outlook]" wrote:



What do you mean by "it disappears"? Do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --

Am Thu, 23 Nov 2006 15:41:01 -0800 schrieb Nick_NZ:

Hi,

I have a VBA that turn emails into tasks in Outlook XP, and for some
reason
it disappears causing the subsequent rule to fail. It usually runs
around
10
times, then the code simply goes away!

I have no idea to why this is occurring, and any help would be

greatly
appreciated.



 




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
COM and VBA George Hester Outlook and VBA 4 October 4th 06 06:12 AM
VBA Question? netnews.comcast.net Outlook and VBA 1 September 28th 06 06:32 PM
VBA guidance vortex2k4 Outlook and VBA 1 July 15th 06 08:10 AM
Outlook and VBA Peter Haynes Outlook and VBA 1 June 22nd 06 12:22 PM
Using VBA for Outlook and VBA for Access within Access Sardonic Outlook and VBA 1 March 17th 06 12:34 PM


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