Creating a Task with VBScript

Status
Not open for further replies.
Y

yannickestrada

Regards.

Hi I´m trying to create a task in a custom Contact form in Outlook. I would

like that the task appears in the Activities tab, but I only get to create

the task in the session, can´t associate with the current contact form.

How I can do that?

I was trying to link the Task Item with the contact form bu that don´t seems

to work.

Thanks for your help.

Yannick
 
K

Ken Slovak - [MVP - Outlook]

You need the contact as a ContactItem. Then get the Links collection of the

new task item and add that ContactItem to the Links collection of the task

using the Links.Add method.

"yannickestrada" <yannickestrada> wrote in message

news:84849952-43E7-40E2-80FC-371F5CD98208@microsoft.com...
> Regards.

> Hi I´m trying to create a task in a custom Contact form in Outlook. I
> would
> like that the task appears in the Activities tab, but I only get to create
> the task in the session, can´t associate with the current contact form.

> How I can do that?

> I was trying to link the Task Item with the contact form bu that don´t
> seems
> to work.

> Thanks for your help.
> Yannick
 
Y

yannickestrada

Thanks I was traying to do the opposite.

But my new code doesn´t seems to work neither.

Set myTask = Application.CreateItem(3)

myTask.Subject = "..."

myTask.DueDate #17/08/09#

myTask.Save

Set colLinks = myTask.Links

colLinks.Add(Item)

How I get the current form as a ContactItem is not enough with Item?

Regards.
wrote:


> You need the contact as a ContactItem. Then get the Links collection of the
> new task item and add that ContactItem to the Links collection of the task
> using the Links.Add method.

> >

>

> "yannickestrada" <yannickestrada> wrote in message
> news:84849952-43E7-40E2-80FC-371F5CD98208@microsoft.com...
> > Regards.
> > Hi I´m trying to create a task in a custom Contact form in Outlook. I
> > would
> > like that the task appears in the Activities tab, but I only get to create
> > the task in the session, can´t associate with the current contact form.
> > How I can do that?
> > I was trying to link the Task Item with the contact form bu that don´t
> > seems
> > to work.
> > Thanks for your help.
> > Yannick


>
 
Y

yannickestrada

I get the error when I call: colLinks.Add(Item)

"yannickestrada" wrote:


> Thanks I was traying to do the opposite.

> But my new code doesn´t seems to work neither.

> Set myTask = Application.CreateItem(3)
> myTask.Subject = "..."
> myTask.DueDate #17/08/09#

> myTask.Save

> Set colLinks = myTask.Links
> colLinks.Add(Item)

> How I get the current form as a ContactItem is not enough with Item?

> Regards.

> " - " wrote:
>
> > You need the contact as a ContactItem. Then get the Links collection of the
> > new task item and add that ContactItem to the Links collection of the task
> > using the Links.Add method.
> > > >

> >

> > "yannickestrada" <yannickestrada> wrote in message
> > news:84849952-43E7-40E2-80FC-371F5CD98208@microsoft.com...
> > > Regards.
> > > > Hi I´m trying to create a task in a custom Contact form in Outlook. I
> > > would
> > > like that the task appears in the Activities tab, but I only get to create
> > > the task in the session, can´t associate with the current contact form.
> > > > How I can do that?
> > > > I was trying to link the Task Item with the contact form bu that don´t
> > > seems
> > > to work.
> > > > Thanks for your help.
> > > Yannick

> >
 
K

Ken Slovak - [MVP - Outlook]

Item should work if the item is a contact item. Form code is VBScript, so it

only has Variant objects and you can't create a ContactItem reference.

Does it work if you use it as a function:

Set colLinks = myTask.Links

Set oLink = colLinks.Add(Item)

"yannickestrada" <yannickestrada> wrote in message

news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> I get the error when I call: colLinks.Add(Item)

> "yannickestrada" wrote:
>
> > Thanks I was traying to do the opposite.
>

>> But my new code doesn´t seems to work neither.
>

>> Set myTask = Application.CreateItem(3)
> > myTask.Subject = "..."
> > myTask.DueDate #17/08/09#
>

>> myTask.Save
>

>> Set colLinks = myTask.Links
> > colLinks.Add(Item)
>

>> How I get the current form as a ContactItem is not enough with Item?
>

>> Regards.
 
Y

yannickestrada

Same error. I don´t know what is the problem, because the Item is like

Item.Contact.MyForm, that should work.

Thanks again.
wrote:


> Item should work if the item is a contact item. Form code is VBScript, so it
> only has Variant objects and you can't create a ContactItem reference.

> Does it work if you use it as a function:

> Set colLinks = myTask.Links
> Set oLink = colLinks.Add(Item)

> >

>

> "yannickestrada" <yannickestrada> wrote in message
> news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> >I get the error when I call: colLinks.Add(Item)
> > "yannickestrada" wrote:
> >
> >> Thanks I was traying to do the opposite.
> >
> >> But my new code doesn´t seems to work neither.
> >
> >> Set myTask = Application.CreateItem(3)
> >> myTask.Subject = "..."
> >> myTask.DueDate #17/08/09#
> >
> >> myTask.Save
> >
> >> Set colLinks = myTask.Links
> >> colLinks.Add(Item)
> >
> >> How I get the current form as a ContactItem is not enough with Item?
> >
> >> Regards.


>
 
K

Ken Slovak - [MVP - Outlook]

Try an experiment and do the same code in the Outlook VBA project. Declare

the item as a ContactItem and get it from

Application.ActiveInspector.CurrentItem. Then run the code that creates a

new task and see if the adding to the Links collection works there.

"yannickestrada" <yannickestrada> wrote in message

news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> Same error. I don´t know what is the problem, because the Item is like
> Item.Contact.MyForm, that should work.

> Thanks again.
 
Y

yannickestrada

It´s works, but the task doesn´t appear in the Activities tab. Instead

appears the Form as a Contact element.

Thanks.
wrote:


> Try an experiment and do the same code in the Outlook VBA project. Declare
> the item as a ContactItem and get it from
> Application.ActiveInspector.CurrentItem. Then run the code that creates a
> new task and see if the adding to the Links collection works there.

> >

>

> "yannickestrada" <yannickestrada> wrote in message
> news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> > Same error. I don´t know what is the problem, because the Item is like
> > Item.Contact.MyForm, that should work.
> > Thanks again.


>
 
S

Sue Mosher [MVP]

Here's another idea: Try saving the item before you call Links.Add

Sue Mosher

"yannickestrada" <yannickestrada> wrote in message

news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> Same error. I don´t know what is the problem, because the Item is like
> Item.Contact.MyForm, that should work.

> Thanks again.

> " - " wrote:
>
> > Item should work if the item is a contact item. Form code is VBScript, so
> > it
> > only has Variant objects and you can't create a ContactItem reference.
>

>> Does it work if you use it as a function:
>

>> Set colLinks = myTask.Links
> > Set oLink = colLinks.Add(Item)
>

>> > >

> >

>

>
>
>
>
>
>> "yannickestrada" <yannickestrada> wrote in
> > message
> > news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> > >I get the error when I call: colLinks.Add(Item)
> >>>> > "yannickestrada" wrote:
> >> >> Thanks I was traying to do the opposite.
> > >
>> >> But my new code doesn´t seems to work neither.
> > >
>> >> Set myTask = Application.CreateItem(3)
> > >> myTask.Subject = "..."
> > >> myTask.DueDate #17/08/09#
> > >
>> >> myTask.Save
> > >
>> >> Set colLinks = myTask.Links
> > >> colLinks.Add(Item)
> > >
>> >> How I get the current form as a ContactItem is not enough with Item?
> > >
>> >> Regards.

>

>>
 
Y

yannickestrada

Thanks Sue, that works.

But know I had 2 problems. The task doesn´t appear in the Activities tab

like I expected, instead appears my custom form as a contact element.

The other problem is that the elements in Activities tab sometimes appears

sometimes not. Why is that? I use Outlook 2007.

Regards

"Sue Mosher [MVP]" wrote:


> Here's another idea: Try saving the item before you call Links.Add

> > Sue Mosher
> > >

> "yannickestrada" <yannickestrada> wrote in message
> news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> > Same error. I don´t know what is the problem, because the Item is like
> > Item.Contact.MyForm, that should work.
> > Thanks again.
> > " - " wrote:
> >
> >> Item should work if the item is a contact item. Form code is VBScript, so
> >> it
> >> only has Variant objects and you can't create a ContactItem reference.
> >
> >> Does it work if you use it as a function:
> >
> >> Set colLinks = myTask.Links
> >> Set oLink = colLinks.Add(Item)
> >
> >> > >>

> >>

> >
> >
> >
> >
> >
> >
> >> "yannickestrada" <yannickestrada> wrote in
> >> message
> >> news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> >> >I get the error when I call: colLinks.Add(Item)
> >> >> >> >> > "yannickestrada" wrote:
> >> >> >> Thanks I was traying to do the opposite.
> >> >
> >> >> But my new code doesn´t seems to work neither.
> >> >
> >> >> Set myTask = Application.CreateItem(3)
> >> >> myTask.Subject = "..."
> >> >> myTask.DueDate #17/08/09#
> >> >
> >> >> myTask.Save
> >> >
> >> >> Set colLinks = myTask.Links
> >> >> colLinks.Add(Item)
> >> >
> >> >> How I get the current form as a ContactItem is not enough with Item?
> >> >
> >> >> Regards.
> >
> >>


>
 
S

Sue Mosher [MVP]

Sorry, but I don't understand what you mean by "appears my custom form as a

contact element."

The Activities tab does an on-demand search each time you use it, which can

be quite slow, depending on how many folders are included in the selected

activity group. Maybe you just need to wait longer for the search to

complete.

Sue Mosher

"yannickestrada" <yannickestrada> wrote in message

news:FE88A9FA-46FA-41A9-96AF-52E82C317E7E@microsoft.com...
> Thanks Sue, that works.

> But know I had 2 problems. The task doesn´t appear in the Activities tab
> like I expected, instead appears my custom form as a contact element.

> The other problem is that the elements in Activities tab sometimes appears
> sometimes not. Why is that? I use Outlook 2007.

> Regards

> "Sue Mosher [MVP]" wrote:
>
> > Here's another idea: Try saving the item before you call Links.Add
>

>> "yannickestrada" <yannickestrada> wrote in
> > message
> > news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> > > Same error. I don´t know what is the problem, because the Item is like
> > > Item.Contact.MyForm, that should work.
> >> > Thanks again.
> >> > " - " wrote:
> >> >> Item should work if the item is a contact item. Form code is VBScript,
> > >> so
> > >> it
> > >> only has Variant objects and you can't create a ContactItem reference.
> > >
>> >> Does it work if you use it as a function:
> > >
>> >> Set colLinks = myTask.Links
> > >> Set oLink = colLinks.Add(Item)
> > >
>> >> "yannickestrada" <yannickestrada> wrote in
> > >> message
> > >> news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> > >> >I get the error when I call: colLinks.Add(Item)
> > >>> >>> >>> >> > "yannickestrada" wrote:
> > >>> >> >> Thanks I was traying to do the opposite.
> > >> >
>> >> >> But my new code doesn´t seems to work neither.
> > >> >
>> >> >> Set myTask = Application.CreateItem(3)
> > >> >> myTask.Subject = "..."
> > >> >> myTask.DueDate #17/08/09#
> > >> >
>> >> >> myTask.Save
> > >> >
>> >> >> Set colLinks = myTask.Links
> > >> >> colLinks.Add(Item)
> > >> >
>> >> >> How I get the current form as a ContactItem is not enough with
> > >> >> Item?
> > >> >
>> >> >> Regards.
> > >
>> >>

>

>
>>
 
Y

yannickestrada

Sorry Sue, that was ocurring when I run the code in a VBA project.

My code looks like this:

Set myTask= Application.CreateItem(3)

myTask.Subject = "Subject"

myTask.DueDate = #17/09/2009#

myTask.Save

Item.Save

Set colLinks = myTask.Links

Set oLinks = colLinks.Add(Item)

Now the Add function isn´t the problem. I checked the colLinks count and the

add is happening, but I never see the task in the Activities tab.

Thanks.

"Sue Mosher [MVP]" wrote:


> Sorry, but I don't understand what you mean by "appears my custom form as a
> contact element."

> The Activities tab does an on-demand search each time you use it, which can
> be quite slow, depending on how many folders are included in the selected
> activity group. Maybe you just need to wait longer for the search to
> complete.

> > Sue Mosher
> > >

> "yannickestrada" <yannickestrada> wrote in message
> news:FE88A9FA-46FA-41A9-96AF-52E82C317E7E@microsoft.com...
> > Thanks Sue, that works.
> > But know I had 2 problems. The task doesn´t appear in the Activities tab
> > like I expected, instead appears my custom form as a contact element.
> > The other problem is that the elements in Activities tab sometimes appears
> > sometimes not. Why is that? I use Outlook 2007.
> > Regards
> > "Sue Mosher [MVP]" wrote:
> >
> >> Here's another idea: Try saving the item before you call Links.Add
> >
> >> "yannickestrada" <yannickestrada> wrote in
> >> message
> >> news:1F82F06C-3303-45C4-816A-6B7B4A6BEDCB@microsoft.com...
> >> > Same error. I don´t know what is the problem, because the Item is like
> >> > Item.Contact.MyForm, that should work.
> >> >> > Thanks again.
> >> >> > " - " wrote:
> >> >> >> Item should work if the item is a contact item. Form code is VBScript,
> >> >> so
> >> >> it
> >> >> only has Variant objects and you can't create a ContactItem reference.
> >> >
> >> >> Does it work if you use it as a function:
> >> >
> >> >> Set colLinks = myTask.Links
> >> >> Set oLink = colLinks.Add(Item)
> >> >
> >> >> "yannickestrada" <yannickestrada> wrote in
> >> >> message
> >> >> news:F77401BC-125F-4F45-8EFB-EA176FC86EBE@microsoft.com...
> >> >> >I get the error when I call: colLinks.Add(Item)
> >> >> >> >> >> >> >> >> > "yannickestrada" wrote:
> >> >> >> >> >> Thanks I was traying to do the opposite.
> >> >> >
> >> >> >> But my new code doesn´t seems to work neither.
> >> >> >
> >> >> >> Set myTask = Application.CreateItem(3)
> >> >> >> myTask.Subject = "..."
> >> >> >> myTask.DueDate #17/08/09#
> >> >> >
> >> >> >> myTask.Save
> >> >> >
> >> >> >> Set colLinks = myTask.Links
> >> >> >> colLinks.Add(Item)
> >> >> >
> >> >> >> How I get the current form as a ContactItem is not enough with
> >> >> >> Item?
> >> >> >
> >> >> >> Regards.
> >> >
> >> >
> >
> >
> >>


>
 
K

Ken Slovak - [MVP - Outlook]

Do you save the item again after adding to the Links collection?

"yannickestrada" <yannickestrada> wrote in message

news:7899400B-A303-4880-8014-93D827805E78@microsoft.com...
> Sorry Sue, that was ocurring when I run the code in a VBA project.

> My code looks like this:

> Set myTask= Application.CreateItem(3)
> myTask.Subject = "Subject"
> myTask.DueDate = #17/09/2009#
> myTask.Save

> Item.Save

> Set colLinks = myTask.Links
> Set oLinks = colLinks.Add(Item)

> Now the Add function isn´t the problem. I checked the colLinks count and
> the
> add is happening, but I never see the task in the Activities tab.

> Thanks.
 
S

Sue Mosher [MVP]

The task won't appear on the contact's Activities page until you save the

task.

Which activities list are you looking at -- All Items? Upcoming

Tasks/Appointments? Are you watching until the animation on the right side

of the window stops?

Sue Mosher

"yannickestrada" <yannickestrada> wrote in message

news:7899400B-A303-4880-8014-93D827805E78@microsoft.com...
> Sorry Sue, that was ocurring when I run the code in a VBA project.

> My code looks like this:

> Set myTask= Application.CreateItem(3)
> myTask.Subject = "Subject"
> myTask.DueDate = #17/09/2009#
> myTask.Save

> Item.Save

> Set colLinks = myTask.Links
> Set oLinks = colLinks.Add(Item)

> Now the Add function isn´t the problem. I checked the colLinks count and
> the
> add is happening, but I never see the task in the Activities tab.

> Thanks.

> "Sue Mosher [MVP]" wrote:
>
> > Sorry, but I don't understand what you mean by "appears my custom form as
> > a
> > contact element."
>

>> The Activities tab does an on-demand search each time you use it, which
> > can
> > be quite slow, depending on how many folders are included in the selected
> > activity group. Maybe you just need to wait longer for the search to
> > complete.
>

>> "yannickestrada" <yannickestrada> wrote in
> > message
> > news:FE88A9FA-46FA-41A9-96AF-52E82C317E7E@microsoft.com...
> > > Thanks Sue, that works.
> >> > But know I had 2 problems. The task doesn´t appear in the Activities
> > > tab
> > > like I expected, instead appears my custom form as a contact element.
> >> > The other problem is that the elements in Activities tab sometimes
> > > appears
> > > sometimes not. Why is that? I use Outlook 2007.
> > >
 
Y

yannickestrada

Thanks both!...that was missing. Works nice now.

I appreciate the time you both take to fix my problem.

Regards.

Yannick

"Sue Mosher [MVP]" wrote:


> The task won't appear on the contact's Activities page until you save the
> task.

> Which activities list are you looking at -- All Items? Upcoming
> Tasks/Appointments? Are you watching until the animation on the right side
> of the window stops?

> > Sue Mosher
> > >

> "yannickestrada" <yannickestrada> wrote in message
> news:7899400B-A303-4880-8014-93D827805E78@microsoft.com...
> > Sorry Sue, that was ocurring when I run the code in a VBA project.
> > My code looks like this:
> > Set myTask= Application.CreateItem(3)
> > myTask.Subject = "Subject"
> > myTask.DueDate = #17/09/2009#
> > myTask.Save
> > Item.Save
> > Set colLinks = myTask.Links
> > Set oLinks = colLinks.Add(Item)
> > Now the Add function isn´t the problem. I checked the colLinks count and
> > the
> > add is happening, but I never see the task in the Activities tab.
> > Thanks.
> > "Sue Mosher [MVP]" wrote:
> >
> >> Sorry, but I don't understand what you mean by "appears my custom form as
> >> a
> >> contact element."
> >
> >> The Activities tab does an on-demand search each time you use it, which
> >> can
> >> be quite slow, depending on how many folders are included in the selected
> >> activity group. Maybe you just need to wait longer for the search to
> >> complete.
> >
> >> "yannickestrada" <yannickestrada> wrote in
> >> message
> >> news:FE88A9FA-46FA-41A9-96AF-52E82C317E7E@microsoft.com...
> >> > Thanks Sue, that works.
> >> >> > But know I had 2 problems. The task doesn´t appear in the Activities
> >> > tab
> >> > like I expected, instead appears my custom form as a contact element.
> >> >> > The other problem is that the elements in Activities tab sometimes
> >> > appears
> >> > sometimes not. Why is that? I use Outlook 2007.
> >> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
Wotme Creating a Outlook task in Excel Using Outlook 7
J Text color when creating a new Task is not consistent Using Outlook 1
R Way to correct the window in focus when creating a task from email? Using Outlook 1
H Creating Task by Dragging Item to Task Icon In Navigation Pane Using Outlook 2
B Creating a new TASK using VFP9.0 Outlook VBA and Custom Forms 2
T Creating Task Views Methodically Outlook VBA and Custom Forms 7
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
R Creating a user defined function Outlook VBA and Custom Forms 3
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
O How to prevent CC from showing when creating a new mail? Using Outlook 1
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
B Creating an email with the list of tasks Outlook VBA and Custom Forms 0
L Creating drafts when I thought I was sending Using Outlook 1
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
A Creating Progress Bar or Status Bar Update Outlook VBA and Custom Forms 0
T Outlook creating a folder named: "Unwanted" Using Outlook 3
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
Liza Creating a rule in outlook to filter messages Using Outlook 0
A Are categories still recommended for creating local distribution lists? Using Outlook 3
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
M Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
N Creating New Profile Using Outlook 0
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
M creating email from contact file = 3 emails in To field Using Outlook 3
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
I Creating meeting invite with disabled tentative button Outlook VBA and Custom Forms 5
E Creating email templates for organizational use Using Outlook 0
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
D Creating custom view with VBA Outlook VBA and Custom Forms 2
J Outlook creating unwanted rule on its own Using Outlook 1
R Creating a Room Mailbox with Exchange Online Outlook VBA and Custom Forms 0
A Creating a rule on “Deleted items” folder Using Outlook 1
CMG73 Creating templates with predefined subject and CC Using Outlook 1
G Creating Contact Sub Folders Using Outlook 2
Rupert Dragwater creating gmail account in Outlook 2013 Using Outlook 7
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
2 creating custom stationery Using Outlook 2
A Help creating macro for conditional formatting settings Using Outlook 8
Fozzie Bear Creating Custom Meeting Form Outlook VBA and Custom Forms 6
U Creating a (This computer only) folder within an IMAP account directory Using Outlook 1
A Creating archive rule on the clients by script/ Outlook VBA and Custom Forms 3
J Creating a URL from a message body excerpt before forwarding Using Outlook 2
B Need Help Creating Email Based on Subject w Address in Body Outlook VBA and Custom Forms 1
A Creating rule to create week folder and transfer mail using alert Using Outlook 3
J Creating an "isolated" shared calendar in Outlook Outlook VBA and Custom Forms 1
S Creating custom rule to move if "NAME" is in body but ignore the phrase "Hi NAME" in the search Using Outlook 2
witzker Outlook bug when creating a user defined contact form? Using Outlook 1

Similar threads

Top