+ Reply to Thread
Results 1 to 4 of 4

If Conditions in Word Document

  1. #1
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    If Conditions in Word Document

    Hi Gurus and Experts,

    I have the following codes to find replace text in word file:

    Please Login or Register  to view this content.
    However, I have a problem with this code. If I run excel macro multiple times, "To: " gets added multiple times, as I need to save the word document before closing.

    Hence, I want to execute code only if it has no "To: Total". I tried to add if condition as under:

    Please Login or Register  to view this content.
    However, it did not work to serve my purpose. I seek your guidance to resolve this issue. I appreciate your advices.

    Thank you
    Roshan Shakya

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,909

    Re: If Conditions in Word Document

    Maybe something like this.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    Re: If Conditions in Word Document

    Thank you ByteMarks. This code works however, I have got some other texts such "To : Beyond" that I replace only if it is not available.

    After running the the first With ... End with code that replaces "Total" if "To : Total" is not available, the "IF Condition" does not work on second With .... End with code for "To : Beyond".

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,909

    Re: If Conditions in Word Document

    Perhaps something like this.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populating DocProperty fields in second Word Document from current document
    By AndyE in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2018, 06:09 PM
  2. [SOLVED] How to email word document as an attachment with filename taken from text in document
    By laxminarayana in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2018, 04:46 PM
  3. Replies: 2
    Last Post: 04-19-2013, 07:02 AM
  4. VBA - Create Word Document or Edit Document if exists
    By unstable81 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-11-2013, 08:27 AM
  5. Add text to Existing Word Document if it Doesn't exist create Word Document
    By unstable81 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2013, 12:15 AM
  6. Replies: 0
    Last Post: 06-07-2012, 02:21 PM
  7. [SOLVED] [SOLVED] Changing a Word Document to a CSV Formated Document
    By Team1 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 02-06-2006, 07:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1