?
Solved

Outlook code question: How to add "highlight subject line of task/select all" to code?

Posted on 2010-03-23
6
Medium Priority
?
890 Views
1 Endorsement
Last Modified: 2013-11-25
I just received a solution (http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_25477830.html#a28345637) to turn an Outlook message into a task with some code).  I use a keyboard shortcut to launch a command based on a macro that generates a task from an email.

***I'd like the subject line to be highlighted/"select all"ed so that I can change the subject line easily without having to select all ever y time.

The code I'm using is attached.

Public Sub AddToTasks()

  Dim olTask As Outlook.TaskItem

  Dim olMail As MailItem

  Dim olIns As Inspector

  Dim olExp As Explorer

  Set olTask = Application.CreateItem(olTaskItem)

  Set olExp = Application.ActiveExplorer

  If olExp.CurrentView <> "Messages" Then Exit Sub

  If olExp.Selection.Count <> 1 Then Exit Sub

  Set olMail = olExp.Selection.Item(1)

  With olTask

    .Subject = olMail.Subject

    .Body = olMail.Body

    .StartDate = Now

    .DueDate = DateAdd("d", 7 - Format$(Date, "w", vbSaturday), Date)

    .ReminderSet = False

  olTask.Status = olTaskInProgress

  End With

  Set olIns = olTask.GetInspector

  olIns.Display ("True")

End Sub

Open in new window

1
Comment
Question by:timmer79
  • 3
4 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 28355574
If you always want to start from a blank line then set it blank, otherwise i'm not sure it's possible:

Chris
Public Sub AddToTasks()

  Dim olTask As Outlook.TaskItem

  Dim olMail As MailItem

  Dim olIns As Inspector

  Dim olExp As Explorer

  Set olTask = Application.CreateItem(olTaskItem)

  Set olExp = Application.ActiveExplorer

  If olExp.CurrentView <> "Messages" Then Exit Sub

  If olExp.Selection.count <> 1 Then Exit Sub

  Set olMail = olExp.Selection.Item(1)

  With olTask

    .Subject = ""

    .body = olMail.body

    .StartDate = Now

    .DueDate = DateAdd("d", 7 - Format$(Date, "w", vbSaturday), Date)

    .ReminderSet = False

  olTask.Status = olTaskInProgress

  End With

  Set olIns = olTask.GetInspector

  olIns.Display ("True")
End Sub

Open in new window

0
 

Author Comment

by:timmer79
ID: 28360323
Hmmm... I'm not sure that'd be better.  I'll wait and see if anyone has any ideas.  I guess you're saying keystrokes (or the equivalent) can't be added to code (Ctrl+A)...
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 32956387
I've just repeated my earlier attempts with sendkeys with no success so in the abscence of any other input I stand by my earlier belief that it cannot be done.

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 33389206
As per EE, (http://www.experts-exchange.com/help.jsp#hs=29&hi=405) "The correct answer to some questions is "You can't do that."

I suggest that is the maxim that applies in this case.

Chris
0

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
After a recent Outlook migration from a 2007 to 2010 environment, some issues with Distribution List owners were realized. In this article, I explain how that was rectified.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

588 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