Help with table, macro?

S

Suzanne S. Barnhill

The verb "leach" has a different meaning: "To remove soluble or other
constituents from by the action of a percolating liquid"; "to cause (a
liquid) to filter down through some material; to subject to the washing
action of a filtering liquid." I don't actually find "leech" defined as a
verb except at the Urban Dictionary site: "Originally meaning to be able to
download without uploading. FPT sites many years ago would often have ratios
where people would get a certain amount of downloadable bytes for every byte
they uploaded. Sites that did not have ratios were said to be "leech" sites
because you could download all you wanted without having to upload."

But I agree that Graham's wording as quoted is inoffensive (I had not read
it when I replied and took SS's word for it that "leech" was used as a
noun).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Doug Robbins - Word MVP said:
The word "leech" is used in the following context on Graham's website:

Many people access the material from this web site daily. Most just leech
what they want and run. That's OK, provided they are not selling on the
material as their own; however if your productivity gains from the
material you have used, a donation from the money you have saved, however
small, would help to ensure the continued availability of this resource.

I don't really thing that really makes someone, who takes from the site
and runs, a leech. Sure, the words "take" or "grab" could be used in
place of "leech", or as I would spell it when the word is used as a verb -
leach, though I note most dictionaries give leech as an alternative
spelling.



--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

Suzanne S. Barnhill said:
I think it would be preferable either to freely give what you can in a
sincere desire to help others or straightforwardly sell your products and
consulting advice. If you freely give and those who are grateful choose
to make a donation, then that is all to the good, but I do think that
insulting, berating, or shaming those who don't (perhaps can't) is
counterproductive.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
S

Sesquipedalian Sam

Sub POSTagConvert()
Dim oTable As Table
Dim oRow As Row
Dim nCol As Integer
Set oTable = Selection.Range.Tables(1)
nCol = Selection.Information(wdEndOfRangeColumnNumber)
For Each oRow In oTable.Rows
oRow.Cells(nCol).Range.Text = _
oRow.Cells(nCol).Range.Characters(1)
Next oRow
End Sub

will operate on the column of the table the cursor is in.

Does the following statement select the table where the cursor is
located?

Set oTable = Selection.Range.Tables(1)

What is the function of the "(1)"?

How is it different from the similar statement in your first version?

Set oTable = ActiveDocument.Tables(1)

Does this one select the first table in the active document?



Is there a good book or, better yet, online source that includes both
a good tutorial and a reliable reference for Word macros?
 
S

Sesquipedalian Sam

Sub POSTagConvert()
Dim oTable As Table
Dim oRow As Row
Dim nCol As Integer
Set oTable = Selection.Range.Tables(1)
nCol = Selection.Information(wdEndOfRangeColumnNumber)
For Each oRow In oTable.Rows
oRow.Cells(nCol).Range.Text = _
oRow.Cells(nCol).Range.Characters(1)
Next oRow
End Sub

will operate on the column of the table the cursor is in.

This works perfectly if the cursor is in a table, but gets a runtime
error 5951 if it is not in a table.

Can you give me a statement to tell me if the cursor is in a table so
I can abort the macro?

Thanks
 
S

Sesquipedalian Sam

This works perfectly if the cursor is in a table, but gets a runtime
error 5951 if it is not in a table.

Can you give me a statement to tell me if the cursor is in a table so
I can abort the macro?

This snippet of code seems to work. Are there any provlems with this
solution? Is there a better way>

If Selection.Information(wdWithInTable) <> True Then
MsgBox "The cursor is not in a table", , "MyTableSettings macro"
Exit Sub
End If
 
D

Doug Robbins - Word MVP

No problems with that. It is what I would have suggested if you had not
come up with it.
 
D

Doug Robbins - Word MVP

The (1) creates the reference to the first table in the range represented by
the Selection or the ActiveDocument.

If you wanted the second table in the document, you would use

ActiveDocument.Tables(2)

and if you wanted to do something for all of the tables in a document, you
could use

Dim i as Long
With ActiveDocument
For i = 1 to .Tables.Count
With .Tables(i)
'do something with the table
End With
Next i
End With

or

Dim aTable as Table
For each aTable in ActiveDocument.Tables
'do something with the table
Next aTable
 
S

Sesquipedalian Sam

The (1) creates the reference to the first table in the range represented by
the Selection or the ActiveDocument.

And the "range" is the current selection, right?

If I had 4 tables in a document and had tables 2 & 3 selected, the
statement

Set oTable = Selection.Range.Tables(1)

would get the first table in the selection, which is the second table
in the document. Right?
 
D

Doug Robbins - Word MVP

You can use either

Selection.Range.Tables(1)

or just

Selection.Tables(1)

and yes, if two tables are included in the selection (even if it what is
selected is just the last cell of one table and the first cell of the next
table,

Selection.Tables(1)

will refer to the whole of the table in which the start of the selection is
located

You can see what is being referenced by using

Selection.Tables(1).Select
 
S

Sesquipedalian Sam

You can use either

Selection.Range.Tables(1)

or just

Selection.Tables(1)

and yes, if two tables are included in the selection (even if it what is
selected is just the last cell of one table and the first cell of the next
table,

Selection.Tables(1)

will refer to the whole of the table in which the start of the selection is
located

You can see what is being referenced by using

Selection.Tables(1).Select

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top