![]() |
|
#1
|
||||
|
||||
![]()
Hello Pros,
Another issue, I can't figure out. At times, I have many tables in a row, seperated with 2 or 3 paragraph marks. Upon Selection, so I have the control to select all the tables I wish to remove the paragraph marks B4 or After a table. Since they have the same column size and same number of columns, I wish to merge them together. I already have a macro which I've put the last row with the color Red, so it's OK to merge many tables together. I have succeeded to do a Cut, but on the last one, I'm in a loop HTML Code:
Selection.Select Selection.Find.ClearFormatting With Selection.Find .Text = "^p" .Wrap = wdFindStop .Forward = True .MatchWholeWord = True End With Do While Selection.Find.Execute If Selection.Find.found Then Selection.Cut Else Selection.Find.Execute Replace:=wdReplaceAll End If Loop On Error GoTo 0 Is it possible? Any insights would be sooooooo appreciated. Cendrinne. |
#2
|
||||
|
||||
![]()
Try the following
Code:
Sub Macro1() Dim oRng As Range Set oRng = Selection.Range With oRng.Find .ClearFormatting .Replacement.ClearFormatting Do While .Execute(findText:=Chr(13)) If oRng.Information(wdWithInTable) = False Then If oRng.InRange(Selection.Range) = False Then GoTo lbl_Exit oRng.Text = "" End If Loop End With lbl_Exit: Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
||||
|
||||
![]()
Hello Graham,
It didn't exactly work. If you experiment a table with 3 rows, in each row put A1, B1, C1. Then put 2 paragraphs ''¶'' (paragr) B4 and After the table, then duplicate it 3 times, to end up having: 2 ¶ +Table + 2 ¶ +Table + 2 ¶. Then **Select: 1 ¶ +Table + 2 ¶ +Table + 1 ¶, if you try it, on my side, your macro only removed the first ¶. HOWEVER, as an experiment : I've added a Space or a Tab b4 ''¶'' (paragr), then **Select like above, run your macro, it added the Space or the Tab, into the cells. I already have a macro to delete Leading Space or Tabs in cells, I've tried each one, = Result ==> it merge all the tables without missing a row, and deleted the Leading Space or the Tab. I can't even do a Find and Replace to add a Space or Tab in the Same **Select, unless manually, which defeit the purpose of the macro to remove the ¶ (paragr) in between tables to merge them together, cause that too, I can do manually. It just that in a given document, with a macro, where I've extracted all the tables [less the table header and often less the first column, leaving only the columns with numbers], then pasted onto a New Word document with 2¶ (paragr) in between the tables, I could have 30 tables, of two columns, then different number of columns in other tables. I had already created a macro to have all the columns the same size upon sText as an input box, so for example, put all columns to have 0.9" wide, I was hoping upon Selection, to merge the two columns together, instead of manually deleting the ¶ (paragr). So hoping my Explanation if clearer in order we can find a solution. I'll work on it again tonight, after work, but in the meantime, I welcome any input. Thanks a million again, p.s., on a Great Postive Note, your Macro, doesn't leave me in an eternal Loop ![]() ![]() ![]() Cendrinne |
#4
|
||||
|
||||
![]()
This works for me.
Code:
Sub JoinTables() Dim aRng As Range Set aRng = Selection.Range Do While aRng.Tables.Count > 1 aRng.Tables(aRng.Tables.Count).Range.Previous(Unit:=wdParagraph).Delete Loop End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
||||
|
||||
![]()
Andrew, Finally, this works for me.
I was fedup of manually deleting them, when I know it's the same size and same column numbers. Thank you, Thank you, Thank you, sooooo much. Thank you for your prompt reply and for this tool which will save me tons of time. I love this group. Is there any of you which gives lessons, I could pay to learn and be guided as a coach. I wish to learn and understand more. Please let me know if this is possible. You can even send me a private message, I think it's possible, if you want and have time. Listen, I am very busy myself, but learning and being more efficient, I will make the time ![]() With all my gratitude, for this Forum. Cendrinne. |
![]() |
Tags |
delete paragraph marks |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
a macro to replace paragraph mark with a space applies effect on paragraph marks after the selection | drrr | Word VBA | 2 | 08-24-2021 03:05 AM |
![]() |
Jamal NUMAN | Word | 3 | 02-26-2019 02:33 PM |
![]() |
leonardevens | Word | 1 | 07-13-2015 12:14 PM |
Finding Paragraph Marks | BZee | Word | 4 | 02-14-2015 02:12 PM |
![]() |
Aztec | Word VBA | 2 | 04-02-2013 10:52 PM |