ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   what am i doing wrong (https://www.excelbanter.com/excel-programming/333875-what-am-i-doing-wrong.html)

short_n_curly[_12_]

what am i doing wrong
 

speaks for itsself really trying to send cell entries to outlook new
contacts on an event

Dim OutApp As Outlook.Application
Dim Newcon As Outlook.ContactItem
Set OutApp = CreateObject("Outlook.Application")
Set Newcon = OutApp.CreateItem(olContactItem)

If Target.Row = 14 And Target.Column = 1 Then
With Newcon
..FullName = Range("E1").Value
..MobileTelephoneNumber = Range("A11").Value
..Email1Address = Range("A12").Value
..HomeAddress = Range("A10").Value
End With
End If

no luck so far cant see where the code is wrong or am i being really
silly please help


--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=385290


Vic Eldridge[_3_]

what am i doing wrong
 
Have you set a reference to the Outlook object library ?

From the VBE, select Tools - References, then select your version of Outlook
from the list.


Regards,
Vic Eldridge

"short_n_curly" wrote:


speaks for itsself really trying to send cell entries to outlook new
contacts on an event

Dim OutApp As Outlook.Application
Dim Newcon As Outlook.ContactItem
Set OutApp = CreateObject("Outlook.Application")
Set Newcon = OutApp.CreateItem(olContactItem)

If Target.Row = 14 And Target.Column = 1 Then
With Newcon
.FullName = Range("E1").Value
.MobileTelephoneNumber = Range("A11").Value
.Email1Address = Range("A12").Value
.HomeAddress = Range("A10").Value
End With
End If

no luck so far cant see where the code is wrong or am i being really
silly please help


--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=385290



short_n_curly[_14_]

what am i doing wrong
 

yes i have selected this and still no joy is it the right code even i
beleive it should be but its not havining it


--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=385290


short_n_curly[_15_]

what am i doing wrong
 

am i being totally stupid or do people simply not know the answer lol


--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=385290


Andy Pope

what am i doing wrong
 
Hi,

Surely your With code requires the . otherwise they will be treated a
variables. You might benefit from putting Option Explicit at the top of
your code module.

Dim OutApp As Outlook.Application
Dim Newcon As Outlook.ContactItem
Set OutApp = CreateObject("Outlook.Application")
Set Newcon = OutApp.CreateItem(olContactItem)

If Target.Row = 14 And Target.Column = 1 Then
With Newcon
.FullName = Range("E1").Value
.MobileTelephoneNumber = Range("A11").Value
.Email1Address = Range("A12").Value
.HomeAddress = Range("A10").Value
End With
End If

Cheers
Andy

short_n_curly wrote:
am i being totally stupid or do people simply not know the answer lol



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

short_n_curly[_16_]

what am i doing wrong
 

it has already the option explicit and worksheet change code at the top
of the page and with does have. befor the variables as the code shows
it also has end sub and no bugs identifed by debugging but still when
the event code is activated no joy cant understand why please help


--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=385290


Andy Pope

what am i doing wrong
 
I see the ng post is different from your forum post as in all the .'s
were removed.

You need to include a .Save command.

You might also want to move the createobject & CreateItem inside the
conditional test. No point in processing those line it the target area
is not correct.

Cheers
Andy

short_n_curly wrote:
it has already the option explicit and worksheet change code at the top
of the page and with does have. befor the variables as the code shows
it also has end sub and no bugs identifed by debugging but still when
the event code is activated no joy cant understand why please help



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

short_n_curly[_18_]

what am i doing wrong
 

andy you are a superstar mate i knew the code was bob on no errors wer
being returned all was fine but is was the .save that was missing lol
knew it would be something silly again many thanks mat

--
short_n_curl
-----------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...fo&userid=2157
View this thread: http://www.excelforum.com/showthread.php?threadid=38529



All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com