When I open a document containing a table I do some editing (using VBA) in a
cell off the screen. This causes the document to visually move to the right
to bring the cell onto the screen. Afterwards, I need the top left section of
the document redisplayed on my screen. At the moment, I'm using a workaround
to achieve this - I select cell(1, 1) which is the top left of the document,
insert a period (ie ".") and then delete the period. But, how do I move the
top left corner of the document into view without doing any editing? It would
be much safer for any text already there.

Note: I have also tried turning ScreenUpdating off, but it has no affect on
this.

Thanks for your help.

My current code:

myDocument.Tables.Item(1).Cell(1, 1).Select()
With myDocument.ActiveWindow.Selection
.HomeKey() ' Sets insertion point at start of cell
.Range.InsertAfter(".") ' Inserts a period
.HomeKey(wdLine, wdExtend) ' Selects period
.Delete() ' Deletes period
End With

RE: Move top-left corner of document into view by HelmutWeber

HelmutWeber
Fri May 06 03:23:36 CDT 2005

Hi Phil,

like this:

ActiveWindow.HorizontalPercentScrolled = 0
ActiveWindow.VerticalPercentScrolled = 0

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000

RE: Move top-left corner of document into view by Chuck

Chuck
Fri May 06 05:17:01 CDT 2005

Using Selection to work VBA on your off-screen cell is why your display is
shifting to that cell. Instead use Range and Application.ScreenUpdating, for
example try:

Application.ScreenUpdating = False

With myDocument.Tables(1)
with .Cell(25, 25) 'change cell address
'work VBA magic here
end with
.Cell(1, 1).Range.Select
End With

Application.ScreenUpdating = True

"Phil Vern" wrote:

> When I open a document containing a table I do some editing (using VBA) in a
> cell off the screen. This causes the document to visually move to the right
> to bring the cell onto the screen. Afterwards, I need the top left section of
> the document redisplayed on my screen. At the moment, I'm using a workaround
> to achieve this - I select cell(1, 1) which is the top left of the document,
> insert a period (ie ".") and then delete the period. But, how do I move the
> top left corner of the document into view without doing any editing? It would
> be much safer for any text already there.
>
> Note: I have also tried turning ScreenUpdating off, but it has no affect on
> this.
>
> Thanks for your help.
>
> My current code:
>
> myDocument.Tables.Item(1).Cell(1, 1).Select()
> With myDocument.ActiveWindow.Selection
> .HomeKey() ' Sets insertion point at start of cell
> .Range.InsertAfter(".") ' Inserts a period
> .HomeKey(wdLine, wdExtend) ' Selects period
> .Delete() ' Deletes period
> End With
>
>
>

Re: Move top-left corner of document into view by Jezebel

Jezebel
Fri May 06 05:20:51 CDT 2005

The better approach here is to avoid the selection object entirely -- do all
your work directly on the range objects:

With myDocument.Tables.Item(1).Cell(1, 1).Range
.InsertAfter(".") ' Inserts a period
:

End With



"Phil Vern" <Phil Vern@discussions.microsoft.com> wrote in message
news:0D752654-6462-4AA9-B2FF-49E0F38F039C@microsoft.com...
> When I open a document containing a table I do some editing (using VBA) in
> a
> cell off the screen. This causes the document to visually move to the
> right
> to bring the cell onto the screen. Afterwards, I need the top left section
> of
> the document redisplayed on my screen. At the moment, I'm using a
> workaround
> to achieve this - I select cell(1, 1) which is the top left of the
> document,
> insert a period (ie ".") and then delete the period. But, how do I move
> the
> top left corner of the document into view without doing any editing? It
> would
> be much safer for any text already there.
>
> Note: I have also tried turning ScreenUpdating off, but it has no affect
> on
> this.
>
> Thanks for your help.
>
> My current code:
>
> myDocument.Tables.Item(1).Cell(1, 1).Select()
> With myDocument.ActiveWindow.Selection
> .HomeKey() ' Sets insertion point at start of cell
> .Range.InsertAfter(".") ' Inserts a period
> .HomeKey(wdLine, wdExtend) ' Selects period
> .Delete() ' Deletes period
> End With
>
>
>



RE: Move top-left corner of document into view by Phil

Phil
Fri May 06 10:01:01 CDT 2005

Thanks Helmut - exactly what I was looking for. That will be useful in the
future too.
Thanks for the hint Chuck and Jezebel - I think its a good idea to avoid
using the selection object to eliminate the unwanted movements.

Re: Move top-left corner of document into view by Helmut

Helmut
Sat May 07 06:38:47 CDT 2005

Hi Phil,

you may adjust the values according to your needs.
However, my solution is limited to one-page tables!

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/