Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / April 2008

Tip: Looking for answers? Try searching our database.

How to center the newly added shape?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yang Lu - 22 Apr 2008 08:22 GMT
Hello,

I have struggled for 5 hours for this really really simple task, but still
do not know how to do it in Publisher.

All I want to do is to use Shapes.AddTextBox() to add a text to the center
of the view of the active document. Note that it is not the center of page.
It is the center of the view so that user can see it without scrolling.

Basically, all commands from Publisher menu does that. But I cannot figure
out a way to calculate the left and top location of my shape in vba.

Can somebody help me? Thank you so much!

Signature

Thanks,

Yang Lu
MCAD, MCP.

Ed Bennett - 22 Apr 2008 12:06 GMT
> All I want to do is to use Shapes.AddTextBox() to add a text to the center
> of the view of the active document. Note that it is not the center of page.
> It is the center of the view so that user can see it without scrolling.

I can't bring Mohammed to the mountain, but I can bring the mountain to
Mohammed - create the shape anywhere (e.g. middle of the page; storing a
reference to it in a variable) and then use (Document
object).ActiveView.ScrollShapeIntoView ShapeObject

> Basically, all commands from Publisher menu does that.

This is because all commands from the Publisher menus put the shape
where the user drags, and the user can't drag outside the view of the
active document! Since VBA is controlled by the programmer rather than
the user, it puts the shape where the coder specifies with co-ordinates
- not limited to the active view of the active document.

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

Yang Lu - 22 Apr 2008 17:29 GMT
Thank Ed.

ScrollShapeIntoView() is actually the method I am using now. But it zooms in
the shape, which is not what I want. The real code I am using is something
like:

oldZoom = ActiveView.Zoom; // save zoom
doc.ScrollShapeIntoView(shp);
ActiveView.Zoom = oldZoom; // restore zoom

Now, the problem becomes the view flashes because zoom in and out. I also
tried application.ScreenUpdating = false;
but it does not prevent the flashing.

if there is a way we can calculate the scroll position of the view, it would
be perfect and I can put the shape directly in the center of the view.

Signature

Thanks,

Yang Lu
MCAD, MCP.

> > All I want to do is to use Shapes.AddTextBox() to add a text to the center
> > of the view of the active document. Note that it is not the center of page.
[quoted text clipped - 12 lines]
> the user, it puts the shape where the coder specifies with co-ordinates
> - not limited to the active view of the active document.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.