custom form scripting error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here's the code..

Function UpdateTask()


clt_Client = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_Client2").Value
ctl_Project = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_Project").Value
ctl_ClientLead = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_ClientLead").Value
clt_TeamLead = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_TeamLead").Value
ctl_Categories = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_Categories").Value
ctl_PercentComplete = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_PctComplete").Value
ctl_Status = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("cmbo_Status").Value
ctl_pmo_WBS = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("txt_WBS").Value
ctl_Subject = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("txt_Task").Value
ctl_TotalWork = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("txt_TotalWork").Value
ctl_BillRate = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("txt_BillRate").Value
ctl_Cost = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("txt_Cost").Value
'ctl_Body = Item.GetInspector.ModifiedFormPages("PM
Task")."_DocSiteControl1".Value
'ctl_Complete = Item.GetInspector.ModifiedFormPages("PM
Task").Controls("Complete").Value
b = ItemProperties.Item(39).Value 'Owner
c = ItemProperties.Item("Subject").Value 'Subject
'msgbox a & b & c


Set olNs = Application.GetNameSpace("MAPI")
Set myRecipient = olNs.CreateRecipient(b)
myRecipient.Resolve
If myRecipient.Resolved Then
Set RemoteFolder = olNs.GetSharedDefaultFolder(myRecipient,
olFolderTasks) 'This is where the error comes in...

For i = 1 To RemoteFolder.Items.Count

Set objItem = RemoteFolder.Items(i).ItemProperties

If objItem.Item("Subject").Value = c Then

objItem.Assign
'With RemoteFolder.Items(i)
' objItem.Item("Client").Value = clt_Client
' objItem.Item("Project").Value = ctl_Project
' objItem.Item("ClientLead").Value = ctl_ClientLead
' objItem.Item("TeamLead").Value = clt_TeamLead
' objItem.Item("Categories").Value = ctl_Categories
' objItem.Item("PercentComplete").Value =
ctl_PercentComplete
' objItem.Item("Status").Value = ctl_Status
' objItem.Item("WBS").Value = ctl_pmo_WBS
' objItem.Item("Subject").Value = ctl_Subject
' objItem.Item("Total Work").Value = ctl_TotalWork
' objItem.Item("BillRate").Value = ctl_BillRate
' objItem.Item("Cost").Value = ctl_Cost
' RemoteFolder.Items(i).Save
'End With
msgbox objItem.Item("Subject").Value
End If
Next
End If

'----------------------
The error come from the line: Set RemoteFolder =
olNs.GetSharedDefaultFolder(myRecipient, olFolderTasks)

The error is "invalid procedure call or
argument:Olns.Getshareddefaultfolder..."

The point of the code is to change a task on a shared folder from another
user from the task when opened (and is the custom form). I've been able to
replicate the functionality, only using a few fields in VBA, but I wanted it
to be part of the currently opened custom for.

Any help is greatly appreciated.

Cheers
 
Have you checked to make sure that myRecipient is resolving to an Exchange user and not a record in the user's Contacts folder? Checked permission on the other mailbox's Tasks folder?

BTW, this is not a good way to return a property value, because there is no guarantee that 39 will be the same property every time:

b = ItemProperties.Item(39).Value 'Owner

You should use the name of the property instead and also include the parent object or use the basic syntax:

b = Item.Owner
 
Sue,

The name is resolved to the Exchange server, and I have ownership rights to
the user's tasks..thanks for the tip on property values..

Have you checked to make sure that myRecipient is resolving to an Exchange
user and not a record in the user's Contacts folder? Checked permission on
the other mailbox's Tasks folder?

BTW, this is not a good way to return a property value, because there is no
guarantee that 39 will be the same property every time:

b = ItemProperties.Item(39).Value 'Owner

You should use the name of the property instead and also include the parent
object or use the basic syntax:

b = Item.Owner
 
Also, as I mentioned before, the method works in vba, just not very familiar
with vbscript and thought maybe was a syntax error, but found all the
examples I could and they all look like what I've used..

Have you checked to make sure that myRecipient is resolving to an Exchange
user and not a record in the user's Contacts folder? Checked permission on
the other mailbox's Tasks folder?

BTW, this is not a good way to return a property value, because there is no
guarantee that 39 will be the same property every time:

b = ItemProperties.Item(39).Value 'Owner

You should use the name of the property instead and also include the parent
object or use the basic syntax:

b = Item.Owner
 
One thing I overlooked earlier: You need to declare olFolderTasks as a constant or use its literal value. VBScript knows nothing about ol* constants.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Thanks Sue that fixed that issue.

Cheers
One thing I overlooked earlier: You need to declare olFolderTasks as a
constant or use its literal value. VBScript knows nothing about ol*
constants.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Back
Top