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 / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

object properties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ivano - 30 Apr 2007 21:26 GMT
Hi,
I want to write a macro that will change the
width of the objects which I have selected to 540 points,
Text Wrapping to Top and Bottom
Horizontal Absolute Position 0.5" of the page
Verticle Absolute Position 2" to the top of the page
Lock Anchor
Not move with text

Thanks,
Jean-Guy Marcil - 30 Apr 2007 22:10 GMT
Ivano was telling us:
Ivano nous racontait que :

> Hi,
> I want to write a macro that will change the
[quoted text clipped - 4 lines]
> Lock Anchor
> Not move with text

What type of object?
How were they selected?

Have you tries recording/editing some code?
If so, show us what you have...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Ivano - 30 Apr 2007 22:24 GMT
Sub Macro6()
'
'
   ActiveDocument.Shapes("Object 178").Select
   Selection.ShapeRange.Fill.Visible = msoFalse
   Selection.ShapeRange.Fill.Solid
   Selection.ShapeRange.Fill.Transparency = 0#
   Selection.ShapeRange.Line.Weight = 0.75
   Selection.ShapeRange.Line.DashStyle = msoLineSolid
   Selection.ShapeRange.Line.Style = msoLineSingle
   Selection.ShapeRange.Line.Transparency = 0#
   Selection.ShapeRange.Line.Visible = msoFalse
   Selection.ShapeRange.LockAspectRatio = msoTrue
   Selection.ShapeRange.PictureFormat.Brightness = 0.5
   Selection.ShapeRange.PictureFormat.Contrast = 0.5
   Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
   Selection.ShapeRange.PictureFormat.CropLeft = 0#
   Selection.ShapeRange.PictureFormat.CropRight = 0#
   Selection.ShapeRange.PictureFormat.CropTop = 0#
   Selection.ShapeRange.PictureFormat.CropBottom = 0#
   Selection.ShapeRange.Left = 36#
   Selection.ShapeRange.Top = 144#
   Selection.ShapeRange.RelativeHorizontalPosition = _
       wdRelativeHorizontalPositionPage
   Selection.ShapeRange.RelativeVerticalPosition = _
       wdRelativeVerticalPositionPage
   Selection.ShapeRange.Left = InchesToPoints(0.5)
   Selection.ShapeRange.Top = InchesToPoints(2)
   Selection.ShapeRange.LockAnchor = True
   Selection.ShapeRange.WrapFormat.AllowOverlap = True
   Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
   Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0.1)
   Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
   Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
   Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
   Selection.ShapeRange.WrapFormat.Type = wdWrapTopBottom
End Sub

> Ivano was telling us:
> Ivano nous racontait que :
[quoted text clipped - 13 lines]
> Have you tries recording/editing some code?
> If so, show us what you have...
Ivano - 30 Apr 2007 22:32 GMT
I also should have mentioned that:
I select an area in Excel, copy, then paste special in Word as Excel
workbook link.  If I were to then select the object it has black dots on the
corners and not empty round circles.  All my other objects have round circles
around them.  If I try to record a macro and click the object it's like i
haven't clicked anything but if i click other object it will select and
record the click (the one's with the round circles).  I've redone it dozen
times with the same result...  I think Word is going crazy.

> Sub Macro6()
> '
[quoted text clipped - 51 lines]
> > Have you tries recording/editing some code?
> > If so, show us what you have...
Jean-Guy Marcil - 30 Apr 2007 23:38 GMT
Ivano was telling us:
Ivano nous racontait que :

> I also should have mentioned that:
> I select an area in Excel, copy, then paste special in Word as Excel
[quoted text clipped - 5 lines]
> circles).  I've redone it dozen times with the same result...  I
> think Word is going crazy.

Not really..

It is because your pasted object is inline with text, which is the default
for linked object that you paste in Word.  Inline shapes, as they are called
in VBA, do not have the same properties as Shape objects.

If you start the macro recorder first, and then try to click on an inline
shapes, you will not be able to do so, just as you are not able to click on
a word or a paragraph, you have to get the keyboard arrows to get there.

So, if you first select the shape, and then record a macro to modify the
inline shape size and so on, you get this recorded macro:

   Selection.InlineShapes(1).Fill.Visible = msoFalse
   Selection.InlineShapes(1).Fill.Solid
   Selection.InlineShapes(1).Fill.Transparency = 0#
   Selection.InlineShapes(1).Line.Weight = 0.75
   Selection.InlineShapes(1).Line.Transparency = 0#
   Selection.InlineShapes(1).Line.Visible = msoFalse
   Selection.InlineShapes(1).LockAspectRatio = msoTrue
   Selection.InlineShapes(1).Height = 92.15
   Selection.InlineShapes(1).Width = 203.05
   Selection.InlineShapes(1).PictureFormat.Brightness = 0.5
   Selection.InlineShapes(1).PictureFormat.Contrast = 0.5
   Selection.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic
   Selection.InlineShapes(1).PictureFormat.CropLeft = 0#
   Selection.InlineShapes(1).PictureFormat.CropRight = 0#
   Selection.InlineShapes(1).PictureFormat.CropTop = 0#
   Selection.InlineShapes(1).PictureFormat.CropBottom = 0#

As you can see, inline shapes do not have Text Wrapping, Horizontal Absolute
Position, Vertical Absolute Position or an Anchor because they are like a
character in a line of text.
So, you could use somehting like:

Dim shpConvert As Shape
Dim lngRatio As Single

Set shpConvert = Selection.InlineShapes(1).ConvertToShape

With shpConvert
   lngRatio = CSng(Format(.Width / 540, "#.00"))
   .ScaleWidth lngRatio, True
   .ScaleHeight lngRatio, True
   .WrapFormat.Type = wdWrapTopBottom
   .Top = InchesToPoints(2)
   .Left = InchesToPoints(0.5)
   .LockAnchor = True
End With

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Rate this thread:






 
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.