Jonathan, thanks for your responses. Unfortunately, what you suggested
does not work. This is what I put in:
aCell.Select
Set MyRange = Selection.Range
You know how the VBA editor pops up available options as you type?
Well, back when I had MySelection.InsertRows, the editor said that was
a valid syntax. (The code still did not work, but the editor did
acknowledge it was an option.) However, MyRange.InsertRows does not
appear to be a valid option, and of course neither does the code work
when I run it.
There are 2 things that I know I want to be able to do: InsertRows and
InsertFormula. In the latter case, the Word help says the syntax is:
-----
expression.Formula(Formula, NumberFormat)
expression Required. An expression that returns a Selection object.
InsertFormula Method Example
This example creates a table with three rows and three columns at the
beginning of the active document and then calculates the average of
all the numbers in the first column.
Set MyRange = ActiveDocument.Range(0, 0)
Set myTable = ActiveDocument.Tables.Add(MyRange, 3, 3)
With myTable
.Cell(1, 1).Range.InsertAfter "100"
.Cell(2, 1).Range.InsertAfter "50"
.Cell(3, 1).Select
End With
Selection.InsertFormula Formula:="=Average(Above)"
-----
Unfortunately, I do not seem to be able to return a valid Selection
object, and replacing it with Range does not appear to work either.
You mentioned that there are almost always other ways of doing the
same things. This has also been my experience, but in this case I do
not know what options are open to me. I am open to any suggestions.
Thanks again for your previous insight.
Brandon
-----
Quote:
>Hi Brandon,
>For most things, you can define a Range object variable called MyRange, and
>then replace Selection with MyRange throughout the code.
>There are a few methods of the Selection object that can't be applied to a
>Range object, such as HomeKey, but there are almost always other ways of
>doing the same things.
>With the code sample you just gave, I'm pretty sure it will work using a
>Range variable. Try this
>Dim myRange as Range
>Set myRange = Selection.Range
>If myRange.Information(wdWithInTable) = True Then
> myRange.InsertRows NumRows:=2
> myRange.Borders.Enable =False
>End If