Jump to content
xisto Community
WeaponX

Adding Comma To End Of Line & Concatenating Lines

Recommended Posts

I have a huge word document that I want to be able to add a comma to the end of each line and then concatenate the whole document together. For example:

 

test

testing 1

test 23 4

 

I want that to be something like:

 

test,testing 1,test 23 4

 

I tried doing this using a macro (not very good at), but couldn't get them to come out right. Basically I want to make sure that each line connects to the previous one followed by a comma at the end. My document so far has over 4,300 lines now and growing.

 

Any VBA experts out there or does anyone else know of an easier way to do this?

 

Thanks.

Share this post


Link to post
Share on other sites

I have a huge word document that I want to be able to add a comma to the end of each line and then concatenate the whole document together.  For example:

 

<{POST_SNAPBACK}>

WeaponX,

have you tried replacing paragraphs with commas using Edit->Replace?

To search for a paragraph mark, write "^p" into the input field

(at least, it's like that in my German Word-version).

Calixt

Share this post


Link to post
Share on other sites

Thanks Calixt, I never thought of that before. That will connect all of those lines together? How about the commas? Any easy way to do this? So far, I'm just creating two macros:1. One is to add a comma to the end of a line.2. The second one is basically mimicking what I did with #1 above except I'm running it through a few pages of lines first.Then I save the second macro and run the second macro many times so it gets to the very end.

Share this post


Link to post
Share on other sites

Is there a program that will allow me to have one HUGE line without any limits? I have thousands of lines of text in a Word document and I used the replacement method for paragraphs and that did part of the work. But I still have a lot of lines leftover. I want them ALL to be in one very lone single line only. Word seems to limit this and I tried using other text editors and they were about the same (still have many lines leftover).

Share this post


Link to post
Share on other sites

Is there a program that will allow me to have one HUGE line without any limits? I have thousands of lines of text in a Word document and I used the replacement method for paragraphs and that did part of the work. But I still have a lot of lines leftover. I want them ALL to be in one very lone single line only. Word seems to limit this and I tried using other text editors and they were about the same (still have many lines leftover).

WeaponX,

I am not sure but the reason for your "leftovers" may be that not every line-break is a "paragraph". I understand that the replacement method works well but covers not all the line-breaks in your documents. Maybe there are some "manual line breaks" in your docs which do not have the field code "^p" but "^l".

Share this post


Link to post
Share on other sites

search for ^p and replace it with blank space and comma. For manual line breaks, replace ^l with blank space and comma

-reply by Ankit Jain

Share this post


Link to post
Share on other sites
Appending Text to existing text in a text boxAdding Comma To End Of Line & Concatenating Lines

I have built a telephone key pad using the drawing function of Excel.  Each button is a "Shapes("Group xxx")" and I have assigned a macro to each button so that when I click on each button the number shows up in a text box.  My problem is that when I touch successive buttons the previous number in the text box is over written.  How can I change the code (listed below) so that successive button clicks append numbers to the text box so I can see the entire telephone number I dialed?  The code for button #1 and #2 is as follows:

Sub Group644_Click()'' Button #1 Macro' Macro recorded 12/12/2009 by bg''     ActiveSheet.Shapes("Group 644").Select   ActiveSheet.Shapes("TextBox 656").Select   Selection.Characters.Text = "1" With Selection.Characters(Start:=1, Length:=20).Font   .Name = "Tahoma"   .FontStyle = "Regular"   .Size = 16   .Strikethrough = False   .Superscript = False   .Subscript = False   .OutlineFont = False   .Shadow = False   .Underline = xlUnderlineStyleNone   .ColorIndex = 2   End With   Range("V12").SelectEnd SubSub Group645_Click()'' Button #2 Macro' Macro recorded 12/12/2009 by bg''   ActiveSheet.Shapes("Group 645").Select   ActiveSheet.Shapes("TextBox 656").Select   Selection.Characters.Text = "2"   With Selection.Characters(Start:=1, Length:=20).Font   .Name = "Tahoma"   .FontStyle = "Regular"   .Size = 16   .Strikethrough = False   .Superscript = False   .Subscript = False   .OutlineFont = False   .Shadow = False   .Underline = xlUnderlineStyleNone   .ColorIndex = 2   End With   Range("V12").SelectEnd Sub

-question by Bill George

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.