About replacing word/categories in Outlook contacts

Status
Not open for further replies.
S

SmVmZg

Below is a copy of a thread I started in the Outlook/Contacts forum (in

reverse order) and was told by an MVP that this forum is the correct one for

my current programming question. The paragraph below followed by the code,

then several questions and comments, are my question(s).

--------------------------------------------------Thank you so much for your reply and advice. Using the links you provided I

was able to piece together a macro that did the job. Naturally I want to

improve on it. Below is the macro I used with several lines commented with

two quotes ('') that I would like to make into working parts of the macro but

I don't have the programming knowledge to make that happen. Explanations and

questions follow this macro code:

Sub ChangeCategoryText()

Dim objContactsFolder As Outlook.MAPIFolder

Dim objContacts As Outlook.Items

Dim objContact As Object

Dim iCount, aCount As Integer

Dim strOldCat, strNewCat, strContactFolder As String

' Specify which contact folder to work with

'' strContactFolder = InputBox("Name of contact folder that contains the

category you want to modify.")

'' If strContactFolder = "" Then Exit Sub

Set objContactsFolder = Outlook.ActiveExplorer.CurrentFolder

Set objContacts = objContactsFolder.Items

' Prompt for old and new category names

strOldCat = InputBox("Enter the old category name." & Chr(13) &

"(spelling and capitalization must be exact)")

If strOldCat = "" Then Exit Sub

strNewCat = InputBox("Enter the new category name." & Chr(13) &

"(spelling and capitalization must be exact)")

If strNewCat = "" Then Exit Sub

iCount = 0

aCount = 0

'' MsgBox "Updating categories, please wait..."

' Process the changes

For Each objContact In objContacts

aCount = aCount + 1

If TypeName(objContact) = "ContactItem" Then

If InStr(objContact.Categories, strOldCat) > 0 Then

objContact.Categories = Replace(objContact.Categories,

strOldCat, strNewCat)

objContact.Save

iCount = iCount + 1

'' MsgBox Str$(aCount) & " contacts checked, " & Str$(iCount) &

" updated. Please wait..."

End If

End If

Next

MsgBox Str$(aCount) & " contacts checked, " & Str$(iCount) & " updated."

' Clean up

Set objContact = Nothing

Set objContacts = Nothing

Set objContactsFolder = Nothing

End Sub

1. The first and second lines with two quotes would be a way to select the

folder to be scanned for modification. In this working model the current

default folder is used but the macro would be more flexible if the user could

choose. A way to "pick" the folder from a list of contact folders would be

best.

2. The third and fourth lines with two quotes could serve as status reports

if there is some way to loss the buttons and continue without waiting for

user response. Along with this it would be helpful to disable user input

while the macro is running so as to avoid partial or corrupted changes.

If you know of any ways to accomplish these program modifications please post

here. I can envision a one dialog box solution that would ask for user input

for the three string variables, check for validity of data, and proceed with

regular status reports.

Either way I thank you for your time and attention in helping me with this

seemingly simple, but ultimately complex, category modification.

--------------------------------------------------"Diane Poremsky [MVP]" wrote:


> No. You can use this method to change categories:
> http://www.slipstick.com/outlook/searchreplacecompany.htm
> Group by categories, select a group and right click, categories to remove
> from that category.

> >

>

>

> "Jeff" <Jeff> wrote in message
> news:651D7E8B-F4F9-41CE-8007-9C6FB684EF00@microsoft.com...
> > I would like to replace a word in the Categories field in Contacts with
> > another word (often known as Find and Replace). In the future I may need
> > to
> > do this operation in other fields as well. Is there a way to do this to a
> > group of records/contacts?


>
 
K

Ken Slovak - [MVP - Outlook]

The easiest way to get a folder is to use the NameSpace.PickFolder() method,

which returns a MAPIFolder object. You can't control it only showing or

allowing selection of Contacts folders, but your handler after the code

returns from PickFolder() can test for MAPIFolder.DefaultItemType =

olContactItem to verify it's a Contacts folder. If not just show an error

message and loop back to the dialog call. That will show a treeview of all

folders, much nicer than having the users spell the folder name correctly.

What I'd do for a categories selection dialog would be to iterate the

contents of the folder (Items collection and get all the categories in all

the items into a collection. That will automatically eliminate duplicate

entries if you set the key of each collection entry to the category value.

That would be placed in a list box to prevent spelling errors, the users

could just select from existing categories values.

Then the new category entries can be made from a textbox.

I'd make the dialog display modally and have it set global values for the

selections when the OK button is clicked.

"Jeff" <Jeff> wrote in message

news:6DCE352E-9705-4156-B35F-9C0F0DDBBF9B@microsoft.com...
> Below is a copy of a thread I started in the Outlook/Contacts forum (in
> reverse order) and was told by an MVP that this forum is the correct one
> for
> my current programming question. The paragraph below followed by the code,
> then several questions and comments, are my question(s).

> --------------------------------------------------------------------------------> Thank you so much for your reply and advice. Using the links you provided
> I
> was able to piece together a macro that did the job. Naturally I want to
> improve on it. Below is the macro I used with several lines commented with
> two quotes ('') that I would like to make into working parts of the macro
> but
> I don't have the programming knowledge to make that happen. Explanations
> and
> questions follow this macro code:

> Sub ChangeCategoryText()
> Dim objContactsFolder As Outlook.MAPIFolder
> Dim objContacts As Outlook.Items
> Dim objContact As Object
> Dim iCount, aCount As Integer
> Dim strOldCat, strNewCat, strContactFolder As String

> ' Specify which contact folder to work with
> '' strContactFolder = InputBox("Name of contact folder that contains the
> category you want to modify.")
> '' If strContactFolder = "" Then Exit Sub

> Set objContactsFolder = Outlook.ActiveExplorer.CurrentFolder
> Set objContacts = objContactsFolder.Items

> ' Prompt for old and new category names
> strOldCat = InputBox("Enter the old category name." & Chr(13) &
> "(spelling and capitalization must be exact)")
> If strOldCat = "" Then Exit Sub

> strNewCat = InputBox("Enter the new category name." & Chr(13) &
> "(spelling and capitalization must be exact)")
> If strNewCat = "" Then Exit Sub

> iCount = 0
> aCount = 0
> '' MsgBox "Updating categories, please wait..."

> ' Process the changes
> For Each objContact In objContacts
> aCount = aCount + 1
> If TypeName(objContact) = "ContactItem" Then
> If InStr(objContact.Categories, strOldCat) > 0 Then
> objContact.Categories = Replace(objContact.Categories,
> strOldCat, strNewCat)
> objContact.Save
> iCount = iCount + 1
> '' MsgBox Str$(aCount) & " contacts checked, " & Str$(iCount) &
> " updated. Please wait..."
> End If
> End If
> Next

> MsgBox Str$(aCount) & " contacts checked, " & Str$(iCount) & " updated."

> ' Clean up
> Set objContact = Nothing
> Set objContacts = Nothing
> Set objContactsFolder = Nothing
> End Sub

> 1. The first and second lines with two quotes would be a way to select the
> folder to be scanned for modification. In this working model the current
> default folder is used but the macro would be more flexible if the user
> could
> choose. A way to "pick" the folder from a list of contact folders would be
> best.

> 2. The third and fourth lines with two quotes could serve as status
> reports
> if there is some way to loss the buttons and continue without waiting for
> user response. Along with this it would be helpful to disable user input
> while the macro is running so as to avoid partial or corrupted changes.

> If you know of any ways to accomplish these program modifications please
> post
> here. I can envision a one dialog box solution that would ask for user
> input
> for the three string variables, check for validity of data, and proceed
> with
> regular status reports.

> Either way I thank you for your time and attention in helping me with this
> seemingly simple, but ultimately complex, category modification.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
A Forwarding email and replacing body Outlook VBA and Custom Forms 1
H Replacing the extension symbol "x" with ";" ? Using Outlook 8
R Outlook Express 6: replacing archive after problem Using Outlook 1
C Replacing an existing Exchange Certificate Exchange Server Administration 2
L Calendar in Outlook 2007 replacing items/appointments with a "Copy" Using Outlook 2
A Replacing Outlook 2003 with 2010 Using Outlook 7
C blocking two or more word domains separated by period/dot Using Outlook 4
P Outlook 2013 Word Share doc as Email Attachment now brings up Eudora. Using Outlook 1
Jennifer Murphy Ctrl+Tab sometimes will not move through text a word at a time Using Outlook 1
N How to remove signature formatting from Text in Word (accidentally taken from Outlook) Using Outlook 0
C replace subject line generated by converting a word document to PDF and sending it to an email Using Outlook 8
Diane Poremsky Use Word Macro to Apply Formatting to Email New Slipstick.com Articles 0
iwshim word shortcut to search outlook Using Outlook 3
C Outlook 2016 - converting Word VBA to default Outlook message Outlook VBA and Custom Forms 0
C Merging Word and Access into Outlook Using Outlook 4
Q Why can't I copy image with embedded hyperlink from email to Word Using Outlook 0
Mark Foley Emailing attachment from Word/Excel sends attachment but no message body Using Outlook 0
Diane Poremsky Disable Live Preview in Outlook and Word New Slipstick.com Articles 0
Philip Rose Recreating a WORD Editing Macro to use in Outlook VBA Outlook VBA and Custom Forms 4
D Need to extract a line from a word attachment, and add it to the subject line Outlook VBA and Custom Forms 3
M Unable to email from Word or Excel Using Outlook 11
P Macros in Word 2003 - how to transfer to another Word 2003? Using Outlook 1
J VBS Script (macro) for word to open Outlook template. Outlook VBA and Custom Forms 2
B Outlook to Word Template error Using Outlook 4
J Outlook body to word document Outlook VBA and Custom Forms 11
A Is it possible to remove the word Categories: from task list views? Using Outlook 2
A Application_ItemSend not accessed when sending email outside outlook (i.e. word or send to mail from Using Outlook 7
W Macro to add a word in Subject Line Using Outlook 1
O Copy email content and paste into new Word Document using a different font Using Outlook 1
K Import 2013 Outlook Contact Address into Word Using Outlook 36
J "Specific word in body" question Using Outlook 1
D opening Word Document in a business contact? BCM (Business Contact Manager) 3
Z Send mail and contents of body from ms word document Using Outlook 1
O Choosing Sending Email Address from Word Using Outlook 5
C Printing Outlook Form Controls via Word Using Outlook 11
S Highlighter colors limited in Outlook 2007 and Word 2007 Using Outlook 1
L Macro to Open a Specific Word Document - Outlook 2007 Using Outlook 17
O Outlook 2010 does not open MS Word attachments Using Outlook 1
R Using Word/OL 2010 to generate personalized email messages Using Outlook 1
S send email attachment from word, message stripped out Using Outlook 1
M Opening Word Doc's in Adobe Acrobat Pro Using Outlook 9
D Word Wrap Subject Using Outlook 1
C Outlook editing won't select just one word Using Outlook 1
B MS Office 2010: Word email merge not selecting default Outlook account Using Outlook 1
T Word attached files open Word. Excel files open Picture Manager!! Using Outlook 2
C Outlook 2010 some messages received have no word wrap Using Outlook 1
G No word wrap in HTML email. Using Outlook 8
D Work Signature into Outlook 07 using WORD 07 Using Outlook 0
H Have lost 'buttons/word clicks' for archiving data Using Outlook 1
I I cannot open Microsoft Word attachments - Message: Works cannot open... Using Outlook 1
Similar threads


















































Top