Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2011, 12:16 PM
Ulodesk Ulodesk is offline Selection doesn't contain the action Windows 7 64bit Selection doesn't contain the action Office 2010 64bit
Word 2013 Expert Cert
Selection doesn't contain the action
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Selection doesn't contain the action

Well, I've tried to learn VBA on my own, but have not gotten very far in two years with little, occasional time to spend on it. My macros are either my own recorded ones or copied from free sources on the web.
At present, my problem is getting two simple macros from Word 2003 and 2007 to work in 2010. I have two which work perfectly in the former two, one to replace double returns with single, and another to replace hard returns with spaces, both of these operating only on selected text. I have no problem recording such macros in 2010 to operate on an entire document.
(In 2007 I have a variants for dealing with text in which each line has a hard return: one for text with tabs beginning paragraphs, and one to insert tabs before removing all the returns and then replacing ^t with ^p^t afterwards.)
The problem is, in 2010 I can't make the selection contain the action. "Search up" and "search down" both continue to the front or end of the document, respectively; "search all" does what it says; "replace all" appears to be the necessary action in any case.
I have tried fiddling with the code, borrowing promising looking lines from other macros, but I simply don't know enough to make it work.
Other macros, such as text formatting, work on a selection without issue.
When recording the macros, I select several or more paragraphs before starting the recording.
These simple macros safe considerable time and frustration in my daily need to reformat text from an ancient word processing computer (not mine), resumes with text copied from who-knows-where or typed by folks who don't know word processing, etc.
I'd be grateful for a source link or actual macros for these two tasks.

Ulodesk
Reply With Quote
  #2  
Old 10-21-2011, 02:20 AM
macropod's Avatar
macropod macropod is offline Selection doesn't contain the action Windows 7 64bit Selection doesn't contain the action Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Ulodesk,

Without seeing your code it's hard to be sure what the problem is. However, I suspect it has to do with your '.Wrap = ' line (if you have one), which should be set to 'wdFindStop'. Try:
Code:
Sub Demo()
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  'Find multiple consecutive paragraph breaks
  .Text = "[^13]{2,}"
  'Replace with a single paragraph break
  .Replacement.Text = "^p"
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-21-2011, 05:59 AM
Ulodesk Ulodesk is offline Selection doesn't contain the action Windows 7 64bit Selection doesn't contain the action Office 2010 64bit
Word 2013 Expert Cert
Selection doesn't contain the action
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Thanks!

Dear Paul,
Right on target, as usual. My thanks once again, and best wishes,

Philip
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selection doesn't contain the action Calling for an action when typing a character ACA Word VBA 7 06-17-2011 10:28 AM
How to link an action on one slide on a powerpoint with the same action on another slevinmj PowerPoint 0 02-24-2011 05:38 AM
Writing a custom action/rule to check outgoing emails ajm218 Outlook 1 02-12-2011 01:52 PM
Change Action Setting Path gskelton PowerPoint 0 02-27-2010 03:20 PM
Highlighted Selection on Action Settings mos7sad PowerPoint 0 10-12-2009 07:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:58 PM.


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