#1
|
|||
|
|||
Get rid of leading spaces before paragraphs
Hi,
I'm not much of a word expert. I'm a programmer and have considered using VBA but am not good at that either. I'm hoping there is a simpler approach. More specifically this is a manuscript that I worked on years ago and am prettying up to present to someone.Not thinking about it I originally used three spaces manually entered as an indentation at the beginning of a paragraph in stead of tabs. I've tried a few things to clear out these soaces but nothing works. My goal is to force all the text be right up against the left hand margin, including the first line of the paragraph. That's how the agent wants it to be. I guess they must have some software that formats the text. Any suggestions would be appreciated. Fig000 |
#2
|
||||
|
||||
Hi Fig,
Try a wildcard Find/Replace, where: Find =^13[ ]{1,} Replace = ^p An alternative is: Find = [ ]{1,}([!^13]@^13) Replace = \1 The first one replaces the spaces following a paragraph break - which is effectively the same as replacing spaces before a paragraph's text - except for the first paragraph in a Section or table cell. The second one replaces the spaces at the start of a paragraph, except for the last paragraph in a table cell. There is no Find/Replace formulation that will locate solitary 'paragraphs' within a table cell. Your publisher probably also won't want multiple paragraph breaks (ie lines created by hitting the Enter key) between your 'real' paragraphs. You can clean those out with another wildcard Find/Replace, where: Find = [^13]{1,} Replace = ^p Likewise, multiple spaces after periods, etc, for which you can use yet another wildcard Find/Replace, where: Find = ( )[ ]{1,} Replace = \1 Note: The correct way to apply the indented formatting you obtained via the spacebar is via first line indenting for the paragraph (eg Format|Paragraph), preferably by defining an appropriate paragraph Style and applying that to the paragraphs of interest. This is most likely what your publisher will do - along with specifying an appropriate before/after space setting for each paragraph.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Macropod,
Thanks for responding. I'll admit these find/replace things are new to me. I will research it. However I wanted to run something by you. I wrote a small .net program that brought in parts of the word doc one character at a time. I found a paragraph by looking at the doc in word and found that at the beginning of paragraph there were two leading "spaces" (I'm not sure what the characters were-I wanted to find the ascii codes of these two characters thinking that there might be some garbage or some Word formatting characters) The odd thing is that I found the last few charactesrs of the previous paragraph then an ascii 13 (a carriage return). At the beginning of the new paragraph with the two spaces, I could only see the first visible letter in the document that was in the paragraph's. In other words the two "spaces" weren't in the file. As a test I went into a copy of the word doc. I was able to get rid of the "spaces" by backspacing over them. If there is something I don't know, such as the fact that some of the formatting characters are not directly in line with the text, please tell me. I could go through this by hand but I'd rather not. Any help would be appreciated. Thanks, Fig000 |
#4
|
||||
|
||||
Hi Fig,
I don't understand what you mean by: Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Macropod,
Yes, I wrote a .net program that read the same word file I'm working on to try to get rid of the "spaces" before the beginning of paragraphs. I thought that the formatting would be linear. In other words, there would be a sentence, a period, a ascii 13 for the end of the paragraph (I didn't see the ascii 10) and then I'd see the characters who occupied the two "spaces". There were no spaces there and in fact there were no two bytes at all. I saw the text that was shown in the word document after the "spaces". So I guess that word documents are not entirely "linear". It seems I can't write a program to fix this automatically. I am not interested in learning the ins and outs of how a word document is structured since it will take a while to figure it out. The "spaces" are still there. I tried the ctrl-a, cntl-e, ctrl-l trick after clearing out all the tabs. I'm not sure what is causing this. Any help would be appreciated. Sorry this is confusing. I'm a programmer, not an office expert damn it!!! :-). Fig000 |
#6
|
||||
|
||||
Hi Fig,
Quote:
Even without knowing what the 'spaces' are, it's possible to delete them via an ordinary Find/Replace, where: Find = ^p^w Replace = ^p This will delete ordinary spaces, non-breaking spaces & tabs following a paragraph break (i.e. at the start of the following paragraph). Alternatively, as a variation of the solution suggested in the first post, you could use a wildcard Find/Replace, where: Find = [ ^s^t]{1,}([!^13]@^13) Replace = \1
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Macropod,
I will learn more about the replaces and maybe they will help me. As for understanding the structure of a word document, I'll point out that I've been deailing with this document from the Word UI and not with a program. Somehow something was inserted before the beginning of some paragraphs, not all of them. My attempts to remove tabs got rid of some of them but not all. I will say two things: 1. I don't think that in the ui of any word processing software I should be able to insert "something" that I can't find and get rid of. If that is a possibility with a UI, then there is something wrong. The most I could have done was to either enter a tab or hand enter spaces. If there is some other effect that occurs that shouldn't be happening I don't know what it is. If you have any ideas I'd like to hear them. 2 Understanding the structure of a word document to the level I've been looking is not something that most people would undertake. Obviously I shouldn't need to know how a doc is structured; that's something that is obviously handled behind the scenes. I would think that with proprietary format this information would be something Microsoft would not want me to know. As I said, the UI would handle everything and any odd structuring that goes on behind the scenes should be transparent to me. I'm sure I could learn VBA and spend weeks finding out how the file is structured so I could use a program to fix it but that defeats the purpose of having a UI that does the work for you. I doubt that many people have tried this. I have exposed the word tags and have seen nothing to give me any idea of why this is happening. So I guess I'll just have to keep hacking until I find the answer. I have considered posting a small fragment of my doc where the mysterious spaces are but I can't see how that would be done.Would that be helpful and is it possible? I will try your find replace suggestions. Thanks for those Maybe they will help. Fig000 |
#8
|
||||
|
||||
Hi Fig,
Quote:
Quote:
BTW: Word 2007 does not use a proprietary format for its native docx/docm files; they're nothing more than a zipped collection of xml files. Change any such file's extension to .zip and you can access the contents with programs like WinZip.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Macropod,
Thanks you for all your help. No never manipulated the doc with a program. I had the mistaken notion that the two "spaces", whatever they were, would show up in a stream of the document. However there is nothing there so it must have something to do with some unknown formatting character somewhere in the vicinity of the "spaces". I doubt I'll find these though I'll keep looking. I did try your find replace and it didn't really seem to recognize the find value you suggested (^13??). So I'll ask how I can post a smal snippet of the document. I didn't see any buttons on this forum that would allow that. Let me know how I can do that. I can only hope that it will something small and obvious to you. Thanks again, Fig000 |
#10
|
||||
|
||||
Hi Fig000,
If there really is nothing there, perhaps they're paragraph indents, not spaces, etc. To attach a document to a post, click on the 'Go Advanced' button, then on the paperclip symbol. The rest is fairly straightforward.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Hi,
I would like to have an answer to the original question. All the find/replace answers were useful if you want to change leading spaces "after" the paragraph mark. But the real question (at least mine) is how to find the beginning of a paragraph. The two things are not the same. Ie. when you replace something in a selection, the first paragraph in the selection would not be found. If you have multiple selections there might be several "first" paragraphs which would not be found. Also the last paragraph mark would replace something which is NOT in the selection. Is there any solution for the original question? Csaba |
#12
|
||||
|
||||
The original question has been answered. If you have a different question, start your own thread instead of trying to resurrect one whose discussion concluded years ago.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
HELP - problem with disappearing spaces | klanch | Word | 3 | 02-11-2011 10:32 AM |
changing font size without changing leading | carolns | Word | 1 | 09-14-2009 12:30 PM |
Eliminate blanc spaces at the beginnig row | Il_Fabietto | Word VBA | 9 | 06-26-2009 05:04 AM |
Spaces After Each Word | jnutella | Word | 0 | 03-04-2009 02:00 PM |
Word to Excel hyperlinks and spaces | gak | Word | 1 | 09-14-2008 08:38 AM |