Position in Text

J

jokobe

I want to make a textbox at the cursor-position.
I know how to make the text box, but how can I establish where the cursor is?
With this:
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 322.85, _
538.85, 216#, 54#).Select
the textbox is always placed at the same position?

Thanks in advance for any helpful hint

jokobe
 
H

Helmut Weber

Hi Jokobe,

like that:

Sub Makro1()
Dim x As Single
Dim y As Single
x = Selection.Information(wdHorizontalPositionRelativeToPage)
y = Selection.Information(wdVerticalPositionRelativeToPage)
ActiveDocument.Shapes.AddTextbox( _
msoTextOrientationHorizontal, x, y, _
100, 100).Select
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Windows XP, Office 200
 
J

jokobe

Hi Helmut,

thanks for you answer, it is working now just the way I want it to work.

Jokobe
 
M

Mark Pranger

I would be interested in knowing how others have found this performing on a
multipage document?

My experience has been that the values I get back allow me to place the item
on a location on the first page of the document even if I am on the 2nd or
3rd page of the document.

Thanks
M
 
H

Helmut Weber

Hi Mark,
My experience has been that the values I get back allow me to place the item
on a location on the first page of the document even if I am on the 2nd or
3rd page of the document.

it is the selection, which defines the page,
where the textbox is inserted. It is not enough
just to scroll to the page, where you want a
textbox to be inserted. You have to select
something on the actual page.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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