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 / October 2006

Tip: Looking for answers? Try searching our database.

Determine position in table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Compass Rose - 27 Oct 2006 17:33 GMT
I have a macro that I want to restrict the user from using when the insertion
point is only in column 1 of table 4. I have been using  
'Selection.Information(wdWithInTable)' in other macros but is not specific
enough for this application.

What code can I use to accomplish this?

TIA
David
Jezebel - 27 Oct 2006 18:30 GMT
If Selection.Information(wdWithInTable) then
   If Selection.Tables(1).range.start =
activedocument.tables(3).range.start and _
       Selection.Cells(1).ColumnIndex = 4 then ...

>I have a macro that I want to restrict the user from using when the
>insertion
[quoted text clipped - 6 lines]
> TIA
> David
Compass Rose - 27 Oct 2006 19:06 GMT
Thanks, Jezebel. I think you've transposed the table number and column
number. Would the correct code not be:

If Selection.Information(wdWithInTable) then
   If Selection.Tables(4).range.start =
activedocument.tables(4).range.start and _
       Selection.Cells(1).ColumnIndex = 1 then ...

David

> If Selection.Information(wdWithInTable) then
>     If Selection.Tables(1).range.start =
[quoted text clipped - 11 lines]
> > TIA
> > David
Jezebel - 27 Oct 2006 20:42 GMT
Not quite. If the selection is within a table, then Selection.Tables(1) is a
reference to that table. Selection.Tables(4) would refer to the fourth table
within the selection. You're making two tests --

1. Is the selection within the fourth table in the document --

Selection.Tables(1).range.start = ActiveDocument.Tables(4).Range.Start

2. Is the selection within a given column --

Selection.Cells(1).ColumnIndex = x

Note that this could all get tricky if you have nested tables (ie one table
within another), or if the selection included several tables.

> Thanks, Jezebel. I think you've transposed the table number and column
> number. Would the correct code not be:
[quoted text clipped - 22 lines]
>> > TIA
>> > David
Compass Rose - 27 Oct 2006 22:17 GMT
Thanks for the explanation.

No, fortunately I don't have nested tables. I try to keep things simple.

David

> Not quite. If the selection is within a table, then Selection.Tables(1) is a
> reference to that table. Selection.Tables(4) would refer to the fourth table
[quoted text clipped - 37 lines]
> >> > TIA
> >> > David
 
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.