?
Solved

Outlook 2013 Macro - Find Text String in Outlook Contact Body and delete the string

Posted on 2014-09-23
7
Medium Priority
?
576 Views
Last Modified: 2014-10-09
I am looking for a way to remove an unwanted text string in the Notes (Body) section of outlook contacts

I have a vba macro that pages through all contacts and tried to use this code but it isn't working can anybody help?

                If InStr(1, .Body, "Facility Condition Assessment EBlast 09-03-2014 Test Run 01") > 0 Then
                    .Body = Replace(.Body, "==============^pFacility Condition Assessment EBlast 09-03-2014 Test Run 01", "")
                    BodyUpdtCnt = BodyUpdtCnt + 1
                End If

Thanks
0
Comment
Question by:rogerdjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:Calvin Paxson
ID: 40339877
Export the contacts to csv, open with excel, use find replace to replace with unwanted string with nothing, import contacts back.  This may be far easier than troubleshooting your vba macro and should work very well.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40340069
Hi, rogerdjr.

Add .Save on the line after the Replace.
0
 

Author Comment

by:rogerdjr
ID: 40340377
Bluedevilfan

I did have .save just after the code snippet I sent


As for the csv option - I guess it would work, but not the solution I was hoping for thanks
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 2

Expert Comment

by:Calvin Paxson
ID: 40340396
If you are doing this once than the CSV option may be less work however if you need to repeat the process against 10 or more address books doing it programatically would potentially save some time.  The more address books involved the better the macro starts to look.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 40340483
rogerdjr,

Then the code should work assuming that the text you're searching for and the text you're replacing both exist.  Do a simple test.  Create a contact and put "string1" and "string2" in the body.  Save the contact.  Now, modify your code to look for "string1" and if found replace "string2" with nothing.  Run the code and see if it works.  If it does, then the problem isn't the code, it's the string you're looking for or the string you're replacing.
0
 

Author Comment

by:rogerdjr
ID: 40344040
I'll test it over the weekend
0
 

Author Comment

by:rogerdjr
ID: 40370953
I've requested that this question be closed as follows:

Accepted answer: 0 points for rogerdjr's comment #a40344040

for the following reason:

Thanks - works perfectly - sorry it took so long to test
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question