Help,How to change 'page' in word?

B

BcOnline

Hi friends
In word2k vba,I open a document and Insert a pagebreak.Now in page
View,we can see two 'Page' in document.
but if when I want insert some shape(such as line,picture) in second
'Page',I found it's very hard to do.
Because there is no way to refer a Location in second page.
For example.when you use
Dim sp as shape.
Dim Sps as shapes
Set sps = ActiveDocument.Shapes
set sp = Sps.AddPicture("c:\\Test.bmp")
sp.setleft(100)
sp.settop(100)
Well,this picture will be add to Point(100,100),but it is in first page.
By other way I finally find a alternate solution(thru cut(Paste)) for
this problem.but I think that's a so indirect way.
Had known there is no a object called 'Page' in Word VBA.
But how can I refer the other pages in Word2K'S Page View in VBA?

Any comment will be appreciate.
 
C

Cindy M -WordMVP-

Hi BcOnline,

The AddPicture method has an ANCHOR argument. If you want the Shape to be
associated with a particular location (a Word range), you need to specify
the anchor argument. You could, for example

Dim rng as Word.Range

Set rng = ActiveDocument.Range
rng.Collapse wdCollapseEnd
'Now the range is the end of the doc
'and you can Anchor:=rng
In word2k vba,I open a document and Insert a pagebreak.Now in page
View,we can see two 'Page' in document.
but if when I want insert some shape(such as line,picture) in second
'Page',I found it's very hard to do.
Because there is no way to refer a Location in second page.
For example.when you use
Dim sp as shape.
Dim Sps as shapes
Set sps = ActiveDocument.Shapes
set sp = Sps.AddPicture("c:\\Test.bmp")
sp.setleft(100)
sp.settop(100)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
B

BcOnline

Yes
Thanks a lot


Cindy M -WordMVP- said:
Hi BcOnline,

The AddPicture method has an ANCHOR argument. If you want the Shape to be
associated with a particular location (a Word range), you need to specify
the anchor argument. You could, for example

Dim rng as Word.Range

Set rng = ActiveDocument.Range
rng.Collapse wdCollapseEnd
'Now the range is the end of the doc
'and you can Anchor:=rng


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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