Designating where the cursor will land...

C

Claudine

Hi all,

You were all kind enough to help me with a macro a few
weeks ago. Now I've had my team come back and ask me if
there is a way I can have the cursor land in a particular
cell. The tables are very simple and two columns. Right
now, here is one of the macros:

Sub InsertBulletPullout()

Dim InsideTable As Boolean

InsideTable = False

Application.ScreenUpdating = False

With Selection
If .Information(wdWithInTable) Then
.SelectRow
.MoveDown Unit:=wdLine, Count:=1
If .Information(wdWithInTable) Then
.SplitTable
InsideTable = True
End If
End If
End With
ActiveDocument.AttachedTemplate.AutoTextEntries
("Bullets").Insert Where:= _
Selection.Range, RichText:=True

If InsideTable Then Selection.Delete

Application.ScreenRefresh
Application.ScreenUpdating = False

End Sub

Is there a way to have the cursor land in either the
right or left column?

Thank you in advance,

Claudine
 
J

Jezebel

'Where the cursor will land' actually defining the selection. You can put
the cursor into cell one of a table using Table.Cells(1,1).Select (where
table is a reference to the table you want to land in)
 
C

Claudine Jalajas

I'm sorry, I don't quite get it. Where would I put this
information into the macro below?

Claudine
 
J

Jezebel

I'm not clear on what you're actually trying to do here. If you want to
macro to finish with the cursor in the first cell, use something like

Selection.Tables(1).Cells(1,1).Select

as the last line of the macro.
 
C

Claudine Jalajas

Well, is it possible to specify the last row and either
column a or column b when we don't know how many rows the
table is?

Claudine
 
G

Greg Maxey

Claudine

Something like would count the rows and put the cursor in the last row (i),
column 2. Use (i,1) to put it in the first column.

Note use of "Cell" rather that "Cells"

Dim i As Integer
i = ActiveDocument.Tables(1).Rows.Count
Selection.Tables(1).Cell(i, 2).Select
Selection.Collapse
 
J

Jezebel

The table.Rows.Count property tells you how many rows there are.


Dim pColumn as long

pColumn = ... 1 or 2, depending on which column you want

with selection.tables(1)
.cells(.rows.count, pColumn).select
end with
 
G

Greg Maxey

Jezebel,

You are the second person suggesting ".cells"

When I try that I get "Compile Error - Method or data member not found"

If I use ".cell" things appear to work correctly.

Can you offer an explanation for this?
 
C

Claudine Jalajas

Thanks Greg,

I don't seem to be able to make it work though. The
cursor just stays wherever I was instead of moving. I
switched it to the column.

Claudine
 
J

Jezebel

Clumsiness on my part. Apologies. In most Microsoft apps, the collection
property is the plural name of the collection members. This is an exception.
In Excel you use Cells(r,c)
 

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