Outlook 2007 Contract Address

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following macro/code that I run, adds the City, State and Zip Code to the Note field, and not the Address Field of the contact. So if I have a contact list that each has an address, but not the City, State and Zip Code, which is the same for all, how can we change this so the Outlook 2007 Contact form when I run the macro, goes to the address of the person, and below the first line, adds the City, State and Zip Code. That would be wonderful.

Dim Ins As outlook.inspector
Dim Document As Word.Document
Dim Word As Word.Application
Dim Selection As Word.Selection
Set Ins = Application.ActiveInspector
Set Document = Ins.WordEditor
Set Word = Document.Application
Set Selection = Word.Selection

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.TypeText Text:="City, State 77001"
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following code puts the City, State and Zip Code in the Contact address, but not below the first line of the address...so what do we add so it puts it below the first line of the address:

Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder

Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem

objItem.UserProperties("Address Selected") = "City, State 77001"


objItem.Save
GoTo Leave
End If

Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


objItem.UserProperties("Address Selected") = "City, State 77001"


objItem.Save

Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I thought maybe you entered a witness protection program. :)

Use this format to enter the address (this is the mailing address field) - where you take the value in the field, add a line break and then the new data.
objItem.MailingAddress = objItem.MailingAddress & vbCrLf & "City, State 77001"
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I have the first line in the contact address, and this did not had the next line..so speficially what to do please:

Sub Test3()

Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder

Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem

objItem.MailingAddress = objItem.MailingAddress & vbCrLf & "City, State 77001"


objItem.Save
GoTo Leave
End If

Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


objItem.MailingAddress = objItem.MailingAddress & vbCrLf & "City, State 77001"


objItem.Save

Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
First, are these existing contacts with something in the address field and the mailing address checkbox checked? If not, you'll need to use .businessaddress or .homeaddress.

If the first line is in a custom field, use that to construct the address - from your original example above:
objitem.businessaddress = objItem.UserProperties("Address Selected") & vbcrlf & "City, state Zip"
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
these are existing contacts with one line in the address field So not sure what to do as it is the standard address in the contact and the field of it is Address Selected.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Address Selected is a custom field you created? This is the format you'll use to add the city state zip line under the street line - I'm not sure what fields they are in so you'll need to fill that part in.
field-where-you-want-address = field-with-street & vbcrlf & "city, state zip"
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
This did it...thanks very very much:

Sub Test3()

Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder

Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem

objItem.UserProperties("Address Selected") = objItem.UserProperties("Address Selected") & vbCrLf & "City, State 77001"


objItem.Save
GoTo Leave
End If

Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


objItem.UserProperties("Address Selected") = objItem.UserProperties("Address Selected") & vbCrLf & "City, State 77001"


objItem.Save

Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
It turns out that the regular address in all contacts is the business address and you have to change it form the droplist to home address....but since I added all the home addresses to the business address the default address, how can I convert the business addresses to the home address ? If create new fields for addresses, the fields are Home Address and Business Address, but the field for the default address is Address Selected, which is for home and business....so when I created the following to change it, it did not work....so is there a way to do it please?

Sub ConvertBusinessAddresstoHomeAddress()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.UserProperties("Home Address") = objItem.UserProperties("Business Address")

objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection

objItem.UserProperties("Home Address") = objItem.UserProperties("Business Address")

objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
To All if this Helps

I added to my contact form, then two additional fields of the Business Address and the Home Address, and the Business Address Display is TextBox50 and the Home Address Display is Textbox51, and whatever you put in the default areas of business and home, it automatically puts the same these fields...so I create the following code that moves the address from Business Address to the Home Address, and deletes the Business Address, and it all shows up in the default address area:

Sub ConvertBusinessAddresstoHomeAddress()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
On Error Resume Next
If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem
objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox51").Text = objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox50").Text
objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox50").Text = ""
objItem.Save
GoTo Leave
End If
Set objSelection = objApp.ActiveExplorer.Selection
For Each objItem In objSelection

objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox51").Text = objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox50").Text
objItem.GetInspector.ModifiedFormPages("General").Controls("TextBox50").Text = ""
objItem.Save
Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It turns out that the regular address in all contacts is the business address and you have to change it form the droplist to home address....but since I added all the home addresses to the business address the default address, how can I convert the business addresses to the home address ? If create new fields for addresses, the fields are Home Address and Business Address, but the field for the default address is Address Selected, which is for home and business....so when I created the following to change it, it did not work....so is there a way to do it please?
That's why i used the mailingaddress field.

Do you want to put the addresses in the business field? My super-duper bulk contacts change can do it. This macro changes the phone numbers fields but you'd use the same method for the address field.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I don't see a macro you mentioned.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Got it! So what do I change for the home address to get the address from the business address of the contact default field?


If .OtherTelephoneNumber <> "" Then
If .MobileTelephoneNumber = "" Then
.MobileTelephoneNumber = .OtherTelephoneNumber
.OtherTelephoneNumber = ""
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I think this is the right logic - if there is a home address, then check to see if the business address field is empty. If it's empty set the business address to equal the home address and remove the address from the home address field.

If so - this should work -

If .homeaddress <> "" Then
If .businessaddress = "" Then
.businessaddress = .homeaddress
.homeaddress= ""
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Oops, you want to put the addresses in the Home address field, not business. Switch the homeaddress and business address fields in that code.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Got it! but i want it to do it for one contact i open or select a list of contacts in a folder. Not just change all in the contact folder. So what do we adjust for that please?
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
S Verwendung von Outlook 2007 Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
S Reboot of frozen windows7 results in changed outlook 2007 settings Using Outlook 1
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
M Configure outlook 2007 to accept digital signatures Using Outlook 2
D Outlook 2007 crashes when opening an email Using Outlook 2
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3
icacream From Outlook 2007 to 2016 ! Using Outlook 9
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S Outlook 2007: Address Cards allow entering text! Why? Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
L Outlook 2007 Separate the Send/Receive functions Using Outlook 2
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
C Move from Outlook 2007 Enterprise (MOE) to Outlook Pro plus 2007 Using Outlook 1
J reinstalling Outlook 2007 asking for user name & password Using Outlook 14
P outlook addin unloaded in office 2007 Using Outlook 0
B Fonts in Outlook 2007 Using Outlook 4
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
C out of space in file group Outlook 2007 Using Outlook 2
A Moving archived contents in Outlook 2007 back into working folders Using Outlook 0
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
M Unable to Configure Gmail Account in Outlook 2007 Using Outlook 1
R Outlook 2007 or 2010 - Lock Down Functionality Outlook VBA and Custom Forms 3
S Outlook 2007, windows 10 Font size Using Outlook 1
Diane Poremsky Manually create a POP3 account in Outlook 2007 New Slipstick.com Articles 0
J Can Click to Drag Custom Form Field But Cannot Drop When Designing in Outlook 2007 Outlook VBA and Custom Forms 2
L Outlook 2007 Font Using Outlook 3
J Outlook 2007 connector and Windows 10 Using Outlook 3
R Outlook 2007 - Shared Accounts and Resources without Exchange Server Using Outlook 0
L Outlook 2007 - Macro Re Search Using Outlook 16
D Outlook (Office) 2007 & Windows 10 Pro Using Outlook 6
MattC Problem with Outlook 2007 & iCloud / duplicate tasks Using Outlook 1
D Outlook 2007 e-mail header- How to set font & font size in received message headers ? Using Outlook 2
P How to switch back from Outlook 2010 to Outlook 2007? Using Outlook 3
L Outlook 2007 Macro to Contact From a Field Using Outlook 3
A Corrupt tasks in Outlook 2007 Using Outlook 1
Diane Poremsky Outlook 2007 with Office 365? New Slipstick.com Articles 0
D Need Genuine Office or Outlook 2007 Using Outlook 3
L Outlook 2007 Criteria Search Using Outlook 9
P Outlook 2007 not sending/receiving until restart (send/receive stuck at __%) Using Outlook 27
Similar threads


















































Top