Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-31-2021, 09:15 PM
jec1 jec1 is offline Trim trailing space macro stopped working Windows 7 32bit Trim trailing space macro stopped working Office 2013
Advanced Beginner
Trim trailing space macro stopped working
 
Join Date: Jan 2012
Posts: 69
jec1 is on a distinguished road
Default Trim trailing space macro stopped working

Hi everyone

Resolved.

This is an old macro that just removes the trailing space for text (quick clean up). But it is not working Windows 10 Office 365 Business Standard.

A
Rny ideas how to make it work? - It doesn't error it just doesn't remove the trailing space in the Word document.

Sub Purge_Trailing_Space()
Dim s As String
On Error Resume Next

With ActiveDocument
If Len(.Range) = 1 Then Exit Sub
s = .Characters.Last.Previous
While s = " " Or s = Chr(13) Or s = Chr(11)
.Characters.Last.Previous = ""
s = .Characters.Last.Previous
Wend
End With



End Sub

Janine

Last edited by jec1; 08-01-2021 at 03:15 PM.
Reply With Quote
  #2  
Old 08-01-2021, 05:56 PM
Guessed's Avatar
Guessed Guessed is online now Trim trailing space macro stopped working Windows 10 Trim trailing space macro stopped working Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,577
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

This is only hitting the last character in the entire document. Is that what you expected to happen or are you wanting this for every paragraph?

Within that scope, it works for me on my machine.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-01-2021, 11:32 PM
jec1 jec1 is offline Trim trailing space macro stopped working Windows 7 32bit Trim trailing space macro stopped working Office 2013
Advanced Beginner
Trim trailing space macro stopped working
 
Join Date: Jan 2012
Posts: 69
jec1 is on a distinguished road
Default

Every paragraph - this is really an old macro - must have left it half finished...

Every para - I just want it to run through the document text top to bottom - and remove trailing space - then call my Table Cell macro.

Below macro seems to work okay.

Sub jec_RemoveTrailingWhitespaceCR(control As IRibbonControl)
'
' RemoveTrailingWhitespace()
' This macro uses find and replace to remove trailing whitespace from the end of all the
' paragraphs in a document. The macro operates on whatever text is currently selected.
'
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^w^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Call jec_Purge_Trailing_SpaceTableCells
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function key F4 stopped working coffent Excel 7 11-15-2020 11:15 AM
Data Entry - Getting spreadsheets back with excess space but the TRIM function doesn't work jhato160 Excel 5 06-17-2016 04:06 AM
Save to PDF stopped working RzB Excel 6 06-26-2014 03:40 AM
Trim trailing space macro stopped working Word stopped working judyn Word 5 10-18-2012 03:09 PM
Trim trailing space macro stopped working Tab key stopped working in Word jgriffin Word 2 06-24-2009 04:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:56 PM.


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