Macro Create Contact and Save

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following code creates a new contact from my form but it will not save and the error is that the parameter value is not valid....what can we do to fix this please?

Sub OpenMyContact()
Dim oContact As outlook.contactItem
Dim oFolder As outlook.MAPIFolder
Set oFolder = Application.Session.GetDefaultFolder(olFolderContacts)
Set oContact = oFolder.Items.Add("IPM.Contact.Contact Form 1.")
oContact.Display
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I'm guessing the problem is not with the macro but with the form, probably with one of the custom fields, specifically one of the values in the fields. you'll need ot figure out which field is the problem - look on the All Fields page and check the user defined fields.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
How does looking a the All Fields page and check the user defined fields show what there is a problem?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Look at the fields that have values. Does anything look amiss? Are other fields reading values from other fields? Are any of the fields without values set to require a value? (It's not the right error message for that though.)

You'll probably need to open the form in the forms designer and check the properties of each custom field - one option is to delete fields that have values, one at a time, and use run this form and try to save it to identify the field that has a bad parameter. As long you do don't publish the form, you won't lose the fields you delete.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following code words fine, no problems and it runs another I created named "PastetoFullName" so when I create the contact, it adds to the Full Name of the contact name I copied from somewhere else....and it put's it in a folder as you see...but, is there away that it creates the contact to a folder I select, not the folder name I put in? This way, I don't have to move contacts all the time etc.

Sub NewContactFromNameSelected()
Dim oContact As outlook.contactItem
Dim oFolder As outlook.MAPIFolder
Set oFolder = Application.Session.GetDefaultFolder(olFolderContacts).Folders("New Contacts")
Set oContact = oFolder.Items.Add("IPM.Contact.Contact Form 1")
oContact.Display
Call PastetoFullName
End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I looked at some other codes re folders and I changed the foregoing to the following, and it creates the contact using my form to the selected folder:

Sub NewContactFromNameSelected()
Dim oContact As outlook.contactItem
Dim oFolder As outlook.MAPIFolder

Set oContact = Application.ActiveExplorer.CurrentFolder.Items.Add("IPM.Contact.Contact Form 1")
oContact.Display
Call PastetoFullName

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
There may be other areas again to do things faster, but given how you gave me a form of a code where when I run it, it adds to the fields of the contact a create, I can call that macro at the end of the code I showed, so it will add to the fields immediately when I create the contact....so also I don't know to mark the last answer as a marked answer...but I so appreciate all you have shown me over the time!!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I can see you are getting to be pretty good at coding. :)

There is a Best Answer link under each reply - I guess I should log in using my test account so i can see what y'all see.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Macro Create Contact and Save Using Outlook 2
S Macro to create a new contact, 2 appointments, and a task Using Outlook 1
C Outlook VBA - Create Macro Move Contact field Item to Another Using Outlook 1
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
B Macro To Create Rule To Export From Certain Folder Email Information in one workbook multiple sheets Outlook VBA and Custom Forms 0
A Create Macro for hyperlink(email) in message body Outlook VBA and Custom Forms 9
S Macro to create notification emails Using Outlook 1
N Macro to create task Using Outlook 1
S Macro to create a new folder with subject line as the folder name Using Outlook 2
P Please Help me Create a Macro ! Using Outlook 2
M How to Create Macro in Visual Basic to add Contacts from Personal Folder Using Outlook 4
R How do I create a macro to put text in certain emails? Outlook VBA and Custom Forms 1
D Create a macro in Outlook to run a rule Outlook VBA and Custom Forms 32
N How Can I create an Outlook Macro to import calendar? Outlook VBA and Custom Forms 1
P How do I create a macro to add contacts from email messages? Outlook VBA and Custom Forms 1
J Macro to create folder in PST file Outlook VBA and Custom Forms 4
G Macro: Create New Message and Auto populate To Field Outlook VBA and Custom Forms 5
S How to create a macro to insert a signature in Outlook 2007 Outlook VBA and Custom Forms 1
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 6
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
S Macro or plug-in to see if specific person was included in this email Outlook VBA and Custom Forms 4
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
V macro runs slower on startup than after Outlook VBA and Custom Forms 3
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
G VBA Macro Calendar Printing Assistant 4
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
R Macro Schedule every day in Outlook Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
D.Moore Folder view settings by VBA macro Outlook VBA and Custom Forms 57
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
V Outlook Macro to show Flagged messages Outlook VBA and Custom Forms 2
O Run macro automatically at sending an email Using Outlook 11
R Retain Original Message When Forwarding With Macro Outlook VBA and Custom Forms 3
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
O Macro - paste as plain text Outlook VBA and Custom Forms 2

Similar threads

Top