Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2009, 08:26 AM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default Eliminate blanc spaces at the beginnig row

Dear all, i have the follow problem:

I have to cancel the blanc spaces at the beginnig row (and only at the beginning row) from a Word file but only from row "x" to row "y".
Do you have any solution?

Ex: i would like to eliminate 6 or 7 blanc spaces for every rows from row 8 to row 25.
Reply With Quote
  #2  
Old 06-23-2009, 01:37 AM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default

Something Could help me please?
Reply With Quote
  #3  
Old 06-23-2009, 08:47 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Eliminate blanc spaces at the beginnig row Eliminate blanc spaces at the beginnig row Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Could you post an example file for us to look at - and please mark the areas that should be removed, thanks.


This way, more people may have a go at answering.
Reply With Quote
  #4  
Old 06-23-2009, 11:40 PM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default

I have posted an example and i have marked the area that i have to remove.
The letter are about 120 and i would have a procedure.


Help me...please!!!

Thanks
Attached Files
File Type: doc Lettera.doc (25.5 KB, 8 views)
Reply With Quote
  #5  
Old 06-24-2009, 09:06 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Eliminate blanc spaces at the beginnig row Eliminate blanc spaces at the beginnig row Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

OK - what you are going to need to do is create a macro that uses the Find and Replace tool that loops through the document.

The following code will: Find "_______" and remove it. This will go through the whole document.
Code:
Find_and_replace_spaces Macro
' Macro recorded 6/24/2009 by Bird_FAT
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "_______"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Do While Selection.Find.Execute
    With Selection
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        .Find.Execute Replace:=wdReplaceOne
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseEnd
        Else
            .Collapse Direction:=wdCollapseStart
        End If
        .Find.Execute
    End With
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Loop
End Sub
Does that help?
Reply With Quote
  #6  
Old 06-25-2009, 05:40 AM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default

Thank you for your collaboration but this isn't the solution. Maybe my english isn't correct.
I post the input file and the output file that would have to obtain!
The macro that you have wrote cancel all blanc spaces. I post also the result for your macro.
The macro have to cancel only blanc spaces on the left of input document in specific area form "PROTOCOLLO" to "DISTINTI SALUTI".

Do you have another solution?
Attached Files
File Type: doc INPUT.doc (23.5 KB, 3 views)
File Type: doc OUTPUT.doc (23.5 KB, 4 views)
File Type: doc Macro output.doc (42.5 KB, 3 views)
Reply With Quote
  #7  
Old 06-25-2009, 05:52 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Eliminate blanc spaces at the beginnig row Eliminate blanc spaces at the beginnig row Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

OK - all you need to do is change two pieces in the code:

First you need to add in the symbol for a paragraph marker - this will mean that the code will then ONLY replace the spaces AFTER a paragrph marker, second alter the 'replace' field to indicate a paragraph marker (see the red indicators below!)

(Use the 'Show/Hide' button to see the symbol)

Code:
Sub Find_and_replace_spaces_Macro()
' Macro re-written 6/25/2009 by Bird_FAT
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^p       "
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Do While Selection.Find.Execute
    With Selection
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        .Find.Execute Replace:=wdReplaceOne
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseEnd
        Else
            .Collapse Direction:=wdCollapseStart
        End If
        .Find.Execute
    End With
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Loop
End Sub
Reply With Quote
  #8  
Old 06-25-2009, 08:32 AM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default

I have added ^p before "PROTOCOLLO" and before "DISTINTI SALUTI" at the begging row. Then I have execudet your code like your post but the result was:

RUN TIME ERROR "5624"

Degub error: Do While Selection.Find.Execute

I think i don't understand correctly your istructions.
Reply With Quote
  #9  
Old 06-26-2009, 04:44 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Eliminate blanc spaces at the beginnig row Eliminate blanc spaces at the beginnig row Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Have you tried copying and pasting my code - as it is written in my last post? I tried it on your files, it worked fine for me!
Reply With Quote
  #10  
Old 06-26-2009, 05:04 AM
Il_Fabietto Il_Fabietto is offline Eliminate blanc spaces at the beginnig row Windows 2K Eliminate blanc spaces at the beginnig row Office 2003
Novice
Eliminate blanc spaces at the beginnig row
 
Join Date: Jun 2009
Posts: 7
Il_Fabietto is on a distinguished road
Default

Ok now it works perfectly!!!!!

Many many many many thanks!!!!!!!!!!!!!!!!!!!!!!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminate blanc spaces at the beginnig row Eliminate paragraph breaks geobruin Word 1 06-12-2009 06:55 AM
Spaces After Each Word jnutella Word 0 03-04-2009 02:00 PM
Eliminate blanc spaces at the beginnig row How to eliminate Header on Contents Page George99 Word 1 12-06-2008 09:59 AM
Word to Excel hyperlinks and spaces gak Word 1 09-14-2008 08:38 AM
protected form with underline fillable spaces rohitsahib Word 0 02-02-2006 10:22 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 12:34 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