Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-18-2012, 07:53 AM
Ulodesk Ulodesk is offline Limiting a macro to a selection Windows 7 64bit Limiting a macro to a selection Office 2010 64bit
Word 2013 Expert Cert
Limiting a macro to a selection
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Macro

Thank you, Paul, but the macro you provided doesn't seem to work -- though I am relcutant to even suggest this. Perhaps I have once again managed to state my problem unclearly. I copied your macro into my VBA and ran it on five selected paragraphs (single lines I had created, each with a hard return), which start several paragraphs down (see attached document). Like my previous, recorded macro, it did not stop with those five lines but continued all the way to the end of the document, merging 20 paragraphs, reporting this, and asking if I wished to check the rest of the document.

In between the time I posted my question and received your reply, I had tried one other thing over the weekend, on a guess, which was to make Wrap false, which work did work. I was going to post this this morning when I saw that you had replied, so I tried yours first. The working macro now reads thus, with a few superfluous lines removed, per your example:


Code:
Sub ParasStripSelected()
'
' ParasStripSelected Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = False
        .Format = False
        .MatchCase = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Attached Files
File Type: docx Lorem ipsum dolor sit ame1.docx (18.1 KB, 12 views)
Reply With Quote
Reply

Tags
limit macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting a macro to a selection Selection is locked Thokkle Word 1 04-01-2012 06:46 PM
How do you add to a selection list? bryanarn Excel 2 03-05-2012 05:04 PM
Macro to populate a text form field based on dropdown selection koloa Word 0 10-20-2011 11:52 AM
Limiting the times that it runs hchbiker PowerPoint 0 02-09-2011 08:36 AM
Limiting a macro to a selection Save Selection cksm4 Word VBA 25 01-30-2011 11:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft