+ Reply to Thread
Results 1 to 4 of 4

WordVBA- Search doc- insert 8 carriage returns if text in line

  1. #1
    Registered User
    Join Date
    03-23-2005
    Posts
    2

    WordVBA- Search doc- insert 8 carriage returns if text in line

    I'm very comfortable with Excel VBA but Word VBA isn't kicking in, clearly due to inexposure that I just can't seem to find time to conquer. Plz forgive and assist?

    We scrape one big block of text and paste it into Word. Simply?, search for text string 'XYZ ABC', and at every instance, go to end of line and insert 8 carriage returns for readability.
    Actually, for icing on the cake, don't do it for last instance (no biggie, I can live with blank lines at end of completed doc). The text string will always be in the last line of the new paragraph I'm trying to build (again, put eight blank lines to make each of the paragraphs more readable.

    I had this macro (someone from this Forum helped me last year?) and unforgivably didn't back it up.. seems easy but I'm struggling! Thanks In Advance - Scott

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: WordVBA- Search doc- insert 8 carriage returns if text in line

    You say "I had this macro (someone from this Forum helped me last year?)", but your post count shows you've only ever made one post on this board. So it's hard to imagine anyone here helped you with this. If they had, finding it would require nothing more than trawling through your old threads.

    As for "go to end of line and insert 8 carriage returns for readability" there are multiple issues with that approach:
    1. Word doesn't work in lines - it works in paragraphs. So, unless your line end = the paragraph end, what you'll get is different results on different PCs
    2. The proper way to reformat a document for readability is to increase the paragraph before/after spacing, preferably by modifying the underlying paragraph Style. Of course, doing this at the Style level requires the document to be using them properly in the first place; the fact you're asking for code to do this with carriage returns suggests otherwise. If your document is using Styles properly, all you need do is to change the relevant Style's definition - no code or searching required.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: WordVBA- Search doc- insert 8 carriage returns if text in line

    Now (3 weeks later) cross-posted at: http://www.msofficeforums.com/word-v...ne-insert.html
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: WordVBA- Search doc- insert 8 carriage returns if text in line

    sbktex , your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. [SOLVED] Referencing text fields with in cell carriage returns
    By cadmanweyland in forum Excel General
    Replies: 4
    Last Post: 04-18-2013, 09:41 PM
  2. [SOLVED] Clearing the carriage returns in a cell with text
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-05-2012, 11:59 AM
  3. Replies: 1
    Last Post: 11-05-2010, 06:09 PM
  4. Replies: 1
    Last Post: 01-26-2006, 12:50 AM
  5. MS Query and Carriage Returns/Line Feeds
    By Gary Brown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2005, 10:24 AM

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