I am using Excel 2007 and Windows 7.
I wish to copy a range in excel, containing stock codes and hyperlinks, to the body of a message in Outlook 2007. I have code that works most of the time (see below), but the SendKeys command is unreliable. It sometimes takes several attempts to work. Is there VBA code that does the same job without using the SendKeys command?
My current prodedure is as follows:
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Set OutlookApp = New Outlook.Application
Set MItem = OutlookApp.CreateItem(olMailItem)
Range("A1:A10").Copy ' copy range of stock codes and hyperlinks
With MItem
.display
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{TAB 4}", Wait:=True 'tab down to body in email
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys ("^v")
End With
Many thanks!
Stefan
I wish to copy a range in excel, containing stock codes and hyperlinks, to the body of a message in Outlook 2007. I have code that works most of the time (see below), but the SendKeys command is unreliable. It sometimes takes several attempts to work. Is there VBA code that does the same job without using the SendKeys command?
My current prodedure is as follows:
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Set OutlookApp = New Outlook.Application
Set MItem = OutlookApp.CreateItem(olMailItem)
Range("A1:A10").Copy ' copy range of stock codes and hyperlinks
With MItem
.display
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys "{TAB 4}", Wait:=True 'tab down to body in email
Application.Wait Now + TimeValue("00:00:01")
Application.SendKeys ("^v")
End With
Many thanks!
Stefan