#1
|
|||
|
|||
How to find out if selection is in table
Hi,
I want to search for a certain style. I need to check if the selection is in a table, and if it is then in which row. Because I search for the style, I have the selection and not the Paragraph.Range. Is there any way to do that? (Actually, what I really want to do is check for cells in which the font is white nd the background is white and then change the font to black. However, even though the paragraph style is correct, the font is set to automatic so when I search for white I don't get anything.) Thanks, Rocky |
#2
|
||||
|
||||
You can get the table and row from the selection
Code:
Dim oTable As Table Dim iRow As Long If Selection.Information(wdWithInTable) Then Set oTable = Selection.Tables(1) iRow = Selection.Rows(1).Index MsgBox "Selection in row " & iRow Else MsgBox "Not in Table" End If
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
||||
|
||||
Word can give you either, so it's not necessary to work with a 'Selection' object. However, as you haven't posted your own code, we can't tell you how to make the appropriate modifications.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Thanks for your help!
It works |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find if the selection is a horizontal line | NevilleT | Word VBA | 4 | 06-26-2016 12:17 AM |
Help required with Selection.Find to search a text file. | Marko | Word VBA | 2 | 10-18-2014 06:32 AM |
VBA to Find and Format Text string defined using Inputbox within selection | sistemalan | Word VBA | 7 | 10-03-2014 07:28 AM |
Excel 2013 Alt F doesn't block selection in find anymore | KatMagic | Excel | 0 | 03-15-2014 12:44 PM |
Automatic find replace after selection in dropdown | vsempoux | Word | 0 | 10-28-2009 08:45 AM |