|
-
Jun 24th, 2006, 06:16 AM
#1
Thread Starter
Lively Member
Delete a line in all cells in table simultaniously
I use Word automation in my VB6 application.
I have a table in my Word doc, has 12 cells.
I have in all cells 2 lines. First line has text second line just the enter (PI sign).
Now i want the second empty line deleted in all cells and in one go, looping through cells is no option.
I believe the lines are available as paragraphs
So something like
Code:
ATable.range.paragraphs(1).delete
So i can't use ATable.range.cells i think because then i have to mention a certain cell.
Any suggestions?
-
Jun 24th, 2006, 03:33 PM
#2
Re: Delete a line in all cells in table simultaniously
If I understand your situation correctly, you will have to go cell by cell. It may be better to parse out the carriage return during the population instead.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 24th, 2006, 03:57 PM
#3
Thread Starter
Lively Member
Re: Delete a line in all cells in table simultaniously
I want to avoid going cell by cell, for timeconsuming reasons, beceause in some situations there can be lots of tables in one document.
Now i have found a simular way of approuching a paragraph (line) of all cells for entire table at once only this is for alignment.
It vertically aligns all first paragraphs of all table cells, i use a spacebefore.
aTable.range.paragraphs(1).Spacebefore = 12
Now this can be just good luck but this alignment works, but i can allso use
aTable.range.paragraphs.Last.Spacebefore = 12
But using this method for editing er deleting a paragraph/line doesn't seem to work
-
Jun 24th, 2006, 08:43 PM
#4
Re: Delete a line in all cells in table simultaniously
i tried your example above but it only worked in 1 cell and paragraphs.last seems to be after the table
VB Code:
For Each atable In ActiveDocument.Tables
For Each acell In atable.Range.Cells
acell.Range.Paragraphs(2).Range.Delete
Next
Next
this code does what you want, but as you said it is a bit slow, took 126 seconds to do 620 tables of 20 cells on my laptop
pete
-
Jun 25th, 2006, 01:38 AM
#5
Thread Starter
Lively Member
Re: Delete a line in all cells in table simultaniously
The example with spacebefore does work for me for alignment tried on two pc's , i can mention it is done directly after a Mailmerge.execute. But doesn't matter maybe some sideeffect.
Now i tryed deleting a certain paragraph and this only is done in one cell like you said.
VB Code:
'This does only delete paragraph in one cell
aTable.range.paragraphs(1).range.delete
'or
aTable.range.paragraphs(2).range.delete
Now preventing the extra enter during populating maybe difficult. Because it comes from selected fields for a Mailmerge and complicated to explain all the steps.
The result is i have really two lines visible
Example:
FirstLine¶
O
The tablecellseparator sign O allso shows as a line. So i realy have to remove the ¶ from the first line. I will look ferther for a fast way to remove it for all cells, if not found i will have to leave the extra enter.
Added info:
Allso the FirstLine mentioned is a field not plain text so {MyFieled}¶
This maybe will make it more difficult to remove the ¶
Last edited by lvermeersch; Jun 25th, 2006 at 01:49 AM.
-
Jun 25th, 2006, 02:19 AM
#6
Thread Starter
Lively Member
Re: Delete a line in all cells in table simultaniously
Okey. I found an easy and fast solution.
Because all the enter ¶ signs in my document or unwanted (each enter at the first and only line)
i can easally find and replace them with a Find.Execute Replace:=wdReplaceAll
I allready tried it and works great :-)
-
Jun 25th, 2006, 02:43 AM
#7
Re: Delete a line in all cells in table simultaniously
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|