shape alignment ,VBA

E

Edward

Hi everybody,
In a VBA project I'm inserting text as watermark in slidemaster ( I have
several designs - templates ) in my presentation.
here is the code
sub InsertWatermark()
Dim ds as design
dim oSho as shape
Set oShp =
ActivePresentation.Slides(1).Design.SlideMaster.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 40, 20)

oShp.TextFrame.TextRange.Text = “TestTestTestTestTestTestâ€
oShp.TextFrame.AutoSize = ppAutoSizeShapeToFitText

oShp.TextFrame.WordWrap = msoFalse

oShp.Left = ActivePresentation.PageSetup.SlideWidth - oShp.Width - 10
oShp.Top = ActivePresentation.PageSetup.SlideHeight - oShp.Height - 20


oShp.ZOrder msoSendToBack
oShp.Cut
For Each ds In ActivePresentation.Designs
ds.SlideMaster.Shapes.Paste
Next


Exit Sub

As you can see I find the shape left position based on slide width ( we use
different slide sizes) and also textbox width. What I'm doing is basically
trying to anchor the textbox to the right bottom corner.
when I run it step by step it positions the textbox correctly based on
textbox width ( sometimes I have very long sentence) but when I run the
entire code somehow it uses the original textbox width which is 40 and
deson't position the textbox correctly.
I thought this is related to autosize to fit so I changed to none in several
location in my code but it didnt help.
Any thoughts?
Thanks,
 
E

Edward

Great. Yes it worked! It was acctually the width not the height causing
problem but the same concept . It was the first time I saw "BoundWidth"
property but it seems at least for textboxes this is more reliable than
shape.width.
Thanks again !
 

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