Solved

Outlook 2010 Macro: add info to Company task field

Posted on 2014-10-19
3
138 Views
Last Modified: 2014-10-22
Dear expert,

Be able to highlight/select several tasks and have an input cell pop up for Company field and in next step this Company field replaces all the info which may have existed in the Company field of the selected tasks.

Br,
JP
0
Comment
Question by:easycapital
3 Comments
 
LVL 48

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
Comment Utility
Hi,

pls try
sub Macro()
strCompany = InputBox("New Company", "Select the new Company name")
For Each itmTsk In Application.ActiveExplorer.Selection.Items  
    itmTask.Company = strCompany
Next
End Sub

Open in new window

Regards
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 250 total points
Comment Utility
I don't know about the objects in older versions of outlook as I don't have a copy to test, but here are some adaptations to Rgonzo's code that will work in Office 2010 and newer.

Sub UpdateCompany()
    Dim strCompany As String
    Dim objTask As Outlook.TaskItem
    Dim i As Integer

    strCompany = InputBox("New Company", "Select the new Company name")

    For i = 1 To Outlook.ActiveExplorer.Selection.Count
        Set objTask = Outlook.ActiveExplorer.Selection.Item(i)
        objTask.Companies = strCompany
        objTask.Save
    Next
    
    MsgBox Outlook.ActiveExplorer.Selection.Count & " task(s) have been update to a new company of " & strCompany
    
End Sub
       

Open in new window

0
 

Author Closing Comment

by:easycapital
Comment Utility
Excellent!

I went with 2nd solution.

Br,
Juan
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now