15,897,181 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by smehta.er (Top 2 by date)
smehta.er
25-Jun-14 14:29pm
View
Address is present at multiple places in the same doc. If I find and replace that with blank, there is a chance that address will be replaced at multiple places with blank. As of now, I found a workaround to delete the address. This address takes around 55 characters after the merge field. I am trying to delete 55 characters once I find the merge field in the doc and observe that the value retrieved from the database is Null or empty. Here is the sample code:
For Each wrdrange In wrdDoc.StoryRanges
With wrdrange.Find
.Forward = True
.ClearFormatting()
.Execute(FindText:=SAMPLEMERGEFIELD)
End With
If UCase(wrdrange.Text) = UCase(Trim(SAMPLEMERGEFIELD)) Then
If Trim(varsamplemergefield) = String.Empty Then
wrdrange.Delete(Unit:=Word.WdUnits.wdCharacter, Count:=55)
Else
wrdrange.Text = varsamplemergefield
End If
End If
Next wrdrange
I am looking for a solution to delete 3 lines rather than deleting 55 characters. I tried changing the units to wdLine but it does not work. Do you have any idea?
smehta.er
23-Jun-14 17:22pm
View
Thanks for the reply. The address is hardcoded in the doc. Are you saying that I would have to find this address in the word document and then delete it?