PDA

View Full Version : run code in whole document



anandbohra
04-29-2008, 11:17 PM
Hi friends,

This is my first post in word section pl help me in running this code in whole document.

I had pasted some data in word but the problem is it occupy hardly 50% of page (with respect to width) so i want to press delete at the end so next line comes up & then press space.

The recorded code is this.

Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=" "
Selection.EndKey Unit:=wdLine


I want to run this code for the whole document

pl help me by giving full code


below is example of my document

row format

afasdfasdfasdfasdfasd
asdfasdfasdfasdfasdfasd
asdfasdfasdfasdfasdfas
asdfasdfasdfasdfasd
asdfasdfasdfasdf

required format (based on normal page width)

afasdfasdfasdfasdfasd asdfasdfasdfasdfasdfasd
asdfasdfasdfasdfasdfas asdfasdfasdfasdfasd
asdfasdfasdfasdf

fumei
04-30-2008, 09:13 AM
There is no need for VBA, if I understand correctly. If those "lines" are terminated by a paragraph mark, just use Replace.

Put ^p in the Find, and " " (a space) in the Replace.

anandbohra
05-02-2008, 03:17 AM
the original data is taken form text file & thus is saperated by enter key

this I come to know by clicking this button show/hide character

some short of opposite P

lucas
05-02-2008, 06:36 AM
That is a paragraph mark. Did you try Gerry's suggestion, it sounds like exactly what you are looking for.

fumei
05-02-2008, 09:16 AM
It sounds like some of the "lines" are NOT terminated by a paragraph mark.

anandbohra
05-05-2008, 02:19 AM
It sounds like some of the "lines" are NOT terminated by a paragraph mark.

You are right as these lines are not terminated by paragraph marks as mr fumei has instructed earlier to remove

when i do as directed by mr fumei the text remains intact i.e. no change to get the same above i have to press delete at the end of line then press space & do the needful
coz original data is harly occupying 60-70% of line ( line in normal A4 page setup)

fumei
05-05-2008, 06:00 AM
1. "I want to run this code for the whole document

pl help me by giving full code"

No.

2. "the original data is taken form text file & thus is saperated by enter key

this I come to know by clicking this button show/hide character
some short of opposite P"

Then they ARE terminated by a paragraph mark (that funny "P" - a "pilcrow"). So, if they are NOT - as they seem not to be - then your statement above is NOT TRUE.

If it is not true, then they are likely separated by manual line breaks. Look in the Replace dialog and click the More button, then the Special button and use...manual line break.