Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help understanding my VB code

24 views
Skip to first unread message

Rhonda

unread,
Oct 28, 2009, 4:53:02 PM10/28/09
to
Can someone tell me what I need to change in the below code that would make
it finish by going to the top of the page that was just pasted:

Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveDown Unit:=wdScreen, Count:=4, Extend:=wdExtend
Selection.MoveUp Unit:=wdScreen, Count:=2, Extend:=wdExtend
ActiveWindow.ActivePane.VerticalPercentScrolled = 49
Selection.Copy
Selection.EndKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
Selection.EndKey Unit:=wdStory
Selection.MoveUp Unit:=wdScreen, Count:=1

The above code worked at one time but now I can't get it to so I tried
something else.

I recorded a new macro, walking thru the steps that were necessary to make
the code do what I needed:

1. go to the top of the page I am on (Selection.HomeKey Unit:=wdWindow)
2. select part of that page (Selection.MoveDown Unit:=wdScreen, Count:=4,
Extend:=wdExtend)
3. copy all of that page (Selection.Copy)
4. go to the bottom of the current page (Selection.EndKey Unit:=wdWindow)
5. create a page break (Selection.InsertBreak Type:=wdPageBreak)
6. paste what was copied (Selection.PasteAndFormat (wdPasteDefault)))
7. go to the top of the new page (Selection.HomeKey Unit:=wdWindow)

But I keep getting an error on it. Run-time error '4120' Bad Parameter. I
go to Debug and it highlights the first line of the code.

Please help me get out of this circle of horror.
--
Thanks,
Rhonda

Ralph

unread,
Oct 28, 2009, 7:52:27 PM10/28/09
to

"Rhonda" <Rho...@discussions.microsoft.com> wrote in message
news:1C883209-9C62-4BDA...@microsoft.com...

> Can someone tell me what I need to change in the below code that would
make
> it finish by going to the top of the page that was just pasted:
>
<sniipped>

>
> But I keep getting an error on it. Run-time error '4120' Bad Parameter.
I
> go to Debug and it highlights the first line of the code.
>
> Please help me get out of this circle of horror.
> --
> Thanks,
> Rhonda

It appears you are using VBA with Word. This newsgroup is populated by users
of the 'Classic' VB development platform (VB6 and lower) having problems
with DirectX.

You will have better success if you post your question to a Word newsgroup,
perhaps microsoft.public.word.programming.

-ralph

0 new messages