Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Word table cell marking routine needed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Planey - 14 Jan 2005 23:27 GMT
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
Doug Robbins - 15 Jan 2005 00:08 GMT
Why not just convert the table to text and then use a wildcard search and
replace to replace consecutive tabs with a single tab?

Signature

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

> Hello,
>
[quoted text clipped - 39 lines]
>
> Bill Planey
Bill Planey - 15 Jan 2005 02:17 GMT
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
Jezebel - 15 Jan 2005 04:27 GMT
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)

> On 1/14/05 6:08 PM, in article OJQNeZp#EHA.1524@TK2MSFTNGP09.phx.gbl, "Doug
> Robbins" <dkr@NOmvpsSPAM.org> wrote:
[quoted text clipped - 7 lines]
>
> Bill Planey
Bill Planey - 15 Jan 2005 15:09 GMT
Thanks, I'll try that.

Bill

On 1/14/05 10:27 PM, in article #A1B6pr#EHA.4028@TK2MSFTNGP15.phx.gbl,

> 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
[quoted text clipped - 34 lines]
>>
>> Bill Planey
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.