Link to home
Start Free TrialLog in
Avatar of timmer79
timmer79Flag for United States of America

asked on

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

I just received a solution (https://www.experts-exchange.com/questions/25477830/Within-Outlook-I-would-like-to-turn-a-message-into-a-task-with-a-keyboard-shortcut.html?anchorAnswerId=28345637#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

ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of timmer79

ASKER

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)...
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
As per EE, (https://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