Hello,

I have a thorny problem that I am hoping for a creative solution to - I have
scripts that convert Word tables to tab-separated text, but because some
cells are (intentionally) left empty in the source document, I need a way to
mark them before they are collapsed so that in their collapsed state there
are not two consecutive tabs left behind, rather, a tab followed by a
placeholder string of my own devising, followed by the second tab. My script
consolidates consecutive tabs into a single tab later (because the vast
majority of consecutive tabs in such documents are truly unnecessary). The
only way to properly re-constitute the table that has an intentionally empty
cell in a number column is to mark the cell beforehand with a placeholder
string.

Sometimes, a cell directly above or below such cells will have a value in
it, so there is the possibility to script something that takes that into
account. But this is not always the case. I suppose a more reliable
scenario would be to check if ANY other cells in the same column have values
in them, which would validate leaving a placeholder in that particular empty
cell.

But what if the column has rows running through it that contain merged
cells? What if the cell is part of a row that is completely empty all the
way across - just there to add vertical space? How can you truly automate
this if there are so many potential forms of interference with a clear-cut
approach?

I don't know if this newsgroup allows attachments, so I have not included
one. But if requested, I'll post again with a sample table that has a
yellow cell that illustrates my dilemma.

BTW, my solution will be VBA code executed via AppleScript.

Many thanks in advance,

Bill Planey

Re: Word table cell marking routine needed by Doug

Doug
Fri Jan 14 18:08:25 CST 2005

Why not just convert the table to text and then use a wildcard search and
replace to replace consecutive tabs with a single tab?

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Bill Planey" <bplaney@sbcglobal.net> wrote in message
news:BE0DB183.12062%bplaney@sbcglobal.net...
> Hello,
>
> I have a thorny problem that I am hoping for a creative solution to - I
> have
> scripts that convert Word tables to tab-separated text, but because some
> cells are (intentionally) left empty in the source document, I need a way
> to
> mark them before they are collapsed so that in their collapsed state there
> are not two consecutive tabs left behind, rather, a tab followed by a
> placeholder string of my own devising, followed by the second tab. My
> script
> consolidates consecutive tabs into a single tab later (because the vast
> majority of consecutive tabs in such documents are truly unnecessary).
> The
> only way to properly re-constitute the table that has an intentionally
> empty
> cell in a number column is to mark the cell beforehand with a placeholder
> string.
>
> Sometimes, a cell directly above or below such cells will have a value in
> it, so there is the possibility to script something that takes that into
> account. But this is not always the case. I suppose a more reliable
> scenario would be to check if ANY other cells in the same column have
> values
> in them, which would validate leaving a placeholder in that particular
> empty
> cell.
>
> But what if the column has rows running through it that contain merged
> cells? What if the cell is part of a row that is completely empty all the
> way across - just there to add vertical space? How can you truly automate
> this if there are so many potential forms of interference with a clear-cut
> approach?
>
> I don't know if this newsgroup allows attachments, so I have not included
> one. But if requested, I'll post again with a sample table that has a
> yellow cell that illustrates my dilemma.
>
> BTW, my solution will be VBA code executed via AppleScript.
>
> Many thanks in advance,
>
> Bill Planey
>



Re: Word table cell marking routine needed by Bill

Bill
Fri Jan 14 20:17:54 CST 2005

On 1/14/05 6:08 PM, in article OJQNeZp#EHA.1524@TK2MSFTNGP09.phx.gbl, "Doug
Robbins" <dkr@NOmvpsSPAM.org> wrote:

> Why not just convert the table to text and then use a wildcard search and
> replace to replace consecutive tabs with a single tab?


Because, as I said, some instances of consecutive tabs need to be preserved
and some don't. That's why the intelligence to put a placeholder string in
_certain_ empty cells is desirable.

Bill Planey


Re: Word table cell marking routine needed by Jezebel

Jezebel
Fri Jan 14 22:27:05 CST 2005

Word tables get seriously tricky if you have merged or split cells. Without
knowing the logic of when you want to preserve the cells and when you don't
it's hard to offer specific suggestions. Are you familiar with the RowIndex
and ColumnIndex properties? You can use these to recognise if a cell is
merged or split, and they are always available -- unlike the Row and Column
properties.

To get a feel for what's going on, create a table with some merged and split
cells of the sort of complexity your code has to deal with. Put some
recognizable text into each cell, then run the following --

Dim pCell As Word.Cell

Set pCell = ActiveDocument.Tables(1).Cell(1, 1)
Do
Debug.Print Left$(pCell.Range, Len(pCell.Range) - 2), _
pCell.RowIndex, pCell.ColumnIndex
Set pCell = pCell.Next
Loop Until pCell Is Nothing


You've probably worked it out already: a cell is empty if the length of its
range = 2 -- a cell always contains vbCr Chr(7)



"Bill Planey" <bplaney@sbcglobal.net> wrote in message
news:BE0DD972.12934%bplaney@sbcglobal.net...
> On 1/14/05 6:08 PM, in article OJQNeZp#EHA.1524@TK2MSFTNGP09.phx.gbl,
"Doug
> Robbins" <dkr@NOmvpsSPAM.org> wrote:
>
> > Why not just convert the table to text and then use a wildcard search
and
> > replace to replace consecutive tabs with a single tab?
>
>
> Because, as I said, some instances of consecutive tabs need to be
preserved
> and some don't. That's why the intelligence to put a placeholder string
in
> _certain_ empty cells is desirable.
>
> Bill Planey
>



Re: Word table cell marking routine needed by Bill

Bill
Sat Jan 15 09:09:51 CST 2005

Thanks, I'll try that.

Bill


On 1/14/05 10:27 PM, in article #A1B6pr#EHA.4028@TK2MSFTNGP15.phx.gbl,
"Jezebel" <madbastard@whitehouse.gov> wrote:

> Word tables get seriously tricky if you have merged or split cells. Without
> knowing the logic of when you want to preserve the cells and when you don't
> it's hard to offer specific suggestions. Are you familiar with the RowIndex
> and ColumnIndex properties? You can use these to recognise if a cell is
> merged or split, and they are always available -- unlike the Row and Column
> properties.
>
> To get a feel for what's going on, create a table with some merged and split
> cells of the sort of complexity your code has to deal with. Put some
> recognizable text into each cell, then run the following --
>
> Dim pCell As Word.Cell
>
> Set pCell = ActiveDocument.Tables(1).Cell(1, 1)
> Do
> Debug.Print Left$(pCell.Range, Len(pCell.Range) - 2), _
> pCell.RowIndex, pCell.ColumnIndex
> Set pCell = pCell.Next
> Loop Until pCell Is Nothing
>
>
> You've probably worked it out already: a cell is empty if the length of its
> range = 2 -- a cell always contains vbCr Chr(7)
>
>
>
> "Bill Planey" <bplaney@sbcglobal.net> wrote in message
> news:BE0DD972.12934%bplaney@sbcglobal.net...
>> On 1/14/05 6:08 PM, in article OJQNeZp#EHA.1524@TK2MSFTNGP09.phx.gbl,
> "Doug
>> Robbins" <dkr@NOmvpsSPAM.org> wrote:
>>
>>> Why not just convert the table to text and then use a wildcard search
> and
>>> replace to replace consecutive tabs with a single tab?
>>
>>
>> Because, as I said, some instances of consecutive tabs need to be
> preserved
>> and some don't. That's why the intelligence to put a placeholder string
> in
>> _certain_ empty cells is desirable.
>>
>> Bill Planey
>>
>
>