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 - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

objTargetFolder can't move item



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 14th 06, 05:47 PM posted to microsoft.public.outlook.program_forms
[email protected]
external usenet poster
 
Posts: 3
Default objTargetFolder can't move item

I am trying to get the JournalMove custom form downloaded from
http://www.outlookcode.com/d/forms/saveinfolder.htm in Outlook 2003
with Exchange

I want to save the item to a public folder. I got the form to work if
I launch it from my personal folder--it works perfect. But the client
needs to somehow connect the contact to the journal entry and since the
"New Journal for Contact" does not seem to work with custom forms, I
was dragging and dropping the contact onto the public folder in which I
want to save the journal item. This launches the custom form, but when
I save I get an error "Can't move the items". I'm afraid I am new to
the Outlook model and I am not sure I completely understand this code,
although I do understand the concept. I've copied the code below as
modified for my environment. Appreciate any help.

(when the code stops, the value of objCopy.Parent.FolderPath =
"\\Public Folders\All Public Folders\Client\Client Journal" while the
value of item.Parent.FolderPath = "\\Mailbox - Bender, Cheryl\Journal",
so I can't understand why it says it cannot move the item.)

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Public Folders/All Public Folders/Client/Client
Journal"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub


Function Item_Open()
If Item.Size = 0 Then
' for appointments and journal items, set Start
' according to option in InitOpts
If mblnResetStart Then
If Item.Class = olAppointment Or _
Item.Class = olJournal Then
Item.Start = Now
End If
End If
If Item.BillingInformation "IsCopy" Then
mblnSaveInTarget = True
Call InitOpts
End If
End If
End Function


Function Item_Write()
Dim objCopy
Dim objTargetFolder
If mblnSaveInTarget And Not Item.Saved Then
Set objTargetFolder = GetMAPIFolder(mstrTargetFolder)
If Not objTargetFolder Is Nothing Then
Item.BillingInformation = "IsCopy"
Set objCopy = Item.Copy
if objCopy.Parent.FolderPath item.Parent.FolderPath then
objCopy.Move objTargetFolder
else
objCopy.Save
end if
Item_Write = False
Item.Close olDiscard
End If
End If

Set objCopy = Nothing
Set objTargetFolder = Nothing
End Function


Function GetMAPIFolder(strName)
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound

Set objNS = Application.GetNamespace("MAPI")

arrName = Split(strName, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If
Next
If blnFound = False Then
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
End If

Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
End Function

  #2  
Old December 14th 06, 06:00 PM posted to microsoft.public.outlook.program_forms
[email protected]
external usenet poster
 
Posts: 3
Default objTargetFolder can't move item

Some additional info, when I went to close out the form and set the
folder back to the default form I saw that it had saved all of my
attempts in the public folder even though the code tripped the error.

Thanks
Cheryl

wrote:
I am trying to get the JournalMove custom form downloaded from
http://www.outlookcode.com/d/forms/saveinfolder.htm in Outlook 2003
with Exchange

I want to save the item to a public folder. I got the form to work if
I launch it from my personal folder--it works perfect. But the client
needs to somehow connect the contact to the journal entry and since the
"New Journal for Contact" does not seem to work with custom forms, I
was dragging and dropping the contact onto the public folder in which I
want to save the journal item. This launches the custom form, but when
I save I get an error "Can't move the items". I'm afraid I am new to
the Outlook model and I am not sure I completely understand this code,
although I do understand the concept. I've copied the code below as
modified for my environment. Appreciate any help.

(when the code stops, the value of objCopy.Parent.FolderPath =
"\\Public Folders\All Public Folders\Client\Client Journal" while the
value of item.Parent.FolderPath = "\\Mailbox - Bender, Cheryl\Journal",
so I can't understand why it says it cannot move the item.)

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Public Folders/All Public Folders/Client/Client
Journal"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub


Function Item_Open()
If Item.Size = 0 Then
' for appointments and journal items, set Start
' according to option in InitOpts
If mblnResetStart Then
If Item.Class = olAppointment Or _
Item.Class = olJournal Then
Item.Start = Now
End If
End If
If Item.BillingInformation "IsCopy" Then
mblnSaveInTarget = True
Call InitOpts
End If
End If
End Function


Function Item_Write()
Dim objCopy
Dim objTargetFolder
If mblnSaveInTarget And Not Item.Saved Then
Set objTargetFolder = GetMAPIFolder(mstrTargetFolder)
If Not objTargetFolder Is Nothing Then
Item.BillingInformation = "IsCopy"
Set objCopy = Item.Copy
if objCopy.Parent.FolderPath item.Parent.FolderPath then
objCopy.Move objTargetFolder
else
objCopy.Save
end if
Item_Write = False
Item.Close olDiscard
End If
End If

Set objCopy = Nothing
Set objTargetFolder = Nothing
End Function


Function GetMAPIFolder(strName)
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound

Set objNS = Application.GetNamespace("MAPI")

arrName = Split(strName, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If
Next
If blnFound = False Then
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
End If

Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
End Function


  #3  
Old December 14th 06, 11:14 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default objTargetFolder can't move item

(when the code stops, the value of objCopy.Parent.FolderPath =
"\\Public Folders\All Public Folders\Client\Client Journal"


In other words, the copy's parent folder is already the target folder. You can't move an item into the folder where it already exists. (Why Item.Parent.FolderPath is the default Journal folder, I can't explain.)

A good solution for your scenario would be a custom contact form with a custom action and code in the CustomActions event handler to create a new journal entry directly in the target folder. Alternatively, you could make the "save in folder" journal form the default form for all journal items, if that would work in your client's environment; see http://www.outlookcode.com/d/newdefaultform.htm

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

wrote in message ps.com...
I am trying to get the JournalMove custom form downloaded from
http://www.outlookcode.com/d/forms/saveinfolder.htm in Outlook 2003
with Exchange

I want to save the item to a public folder. I got the form to work if
I launch it from my personal folder--it works perfect. But the client
needs to somehow connect the contact to the journal entry and since the
"New Journal for Contact" does not seem to work with custom forms, I
was dragging and dropping the contact onto the public folder in which I
want to save the journal item. This launches the custom form, but when
I save I get an error "Can't move the items". I'm afraid I am new to
the Outlook model and I am not sure I completely understand this code,
although I do understand the concept. I've copied the code below as
modified for my environment. Appreciate any help.

(when the code stops, the value of objCopy.Parent.FolderPath =
"\\Public Folders\All Public Folders\Client\Client Journal" while the
value of item.Parent.FolderPath = "\\Mailbox - Bender, Cheryl\Journal",
so I can't understand why it says it cannot move the item.)

Option Explicit

Const olDiscard = 1
Const olAppointment = 26
Const olJournal = 42

Dim mstrTargetFolder
Dim mblnSaveInTarget
Dim mblnResetStart

Sub InitOpts()
' #### USER OPTIONS ####
' set path to target folder here
mstrTargetFolder = "Public Folders/All Public Folders/Client/Client
Journal"
' reset Start date to Now, rather than published form date
mblnResetStart = True
End Sub


Function Item_Open()
If Item.Size = 0 Then
' for appointments and journal items, set Start
' according to option in InitOpts
If mblnResetStart Then
If Item.Class = olAppointment Or _
Item.Class = olJournal Then
Item.Start = Now
End If
End If
If Item.BillingInformation "IsCopy" Then
mblnSaveInTarget = True
Call InitOpts
End If
End If
End Function


Function Item_Write()
Dim objCopy
Dim objTargetFolder
If mblnSaveInTarget And Not Item.Saved Then
Set objTargetFolder = GetMAPIFolder(mstrTargetFolder)
If Not objTargetFolder Is Nothing Then
Item.BillingInformation = "IsCopy"
Set objCopy = Item.Copy
if objCopy.Parent.FolderPath item.Parent.FolderPath then
objCopy.Move objTargetFolder
else
objCopy.Save
end if
Item_Write = False
Item.Close olDiscard
End If
End If

Set objCopy = Nothing
Set objTargetFolder = Nothing
End Function


Function GetMAPIFolder(strName)
Dim objNS
Dim objFolder
Dim objFolders
Dim arrName
Dim I
Dim blnFound

Set objNS = Application.GetNamespace("MAPI")

arrName = Split(strName, "/")
Set objFolders = objNS.Folders
blnFound = False
For I = 0 To UBound(arrName)
For Each objFolder In objFolders
If objFolder.Name = arrName(I) Then
Set objFolders = objFolder.Folders
blnFound = True
Exit For
Else
blnFound = False
End If
Next
If blnFound = False Then
Exit For
End If
Next
If blnFound = True Then
Set GetMAPIFolder = objFolder
End If

Set objNS = Nothing
Set objFolder = Nothing
Set objFolders = Nothing
End Function

 




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
Item.Save and Item.Close Script causes Outlook 2007 to Crash Rayyan Outlook - Using Forms 6 November 25th 06 03:14 AM
How to move focus/selection to a particular contact/item in Explor va Outlook and VBA 1 September 28th 06 11:31 PM
Copy mail item to one folder and then move it to another folder LDMueller Outlook - Using Forms 1 September 15th 06 03:15 PM
Let me move a Calendar item without sending an update Winter Outlook - Calandaring 1 May 29th 06 10:01 PM
Item Move event AtulSureka Outlook and VBA 1 February 24th 06 01:33 PM


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