D
dpomt
Hello,
in Word 2007, setting a Shapes property take quite long.
In my sample below, executing "FormatShape" takes 20 seconds on my machine.
I do not have the exactly value but this was quite faster in Word 2003.
Any ideas why this code executes so slow in Word 2007?
Thanks,
Dieter
--------------------------------------------------------------------
Dim sh1 As Shape
Set sh1 = ActiveDocument.Shapes.AddPicture(FileName:="c:\temp\image.jpg",
LinkToFile:=True, SaveWithDocument:=False)
Call FormatShape(sh1)
--------------------------------------------------------------------
Public Sub FormatShape(sh As Shape)
sh.Fill.Visible = msoTrue
sh.Fill.Solid
sh.Fill.ForeColor.RGB = RGB(255, 255, 255)
sh.Fill.Transparency = 0#
sh.Line.Weight = 0.75
sh.Line.DashStyle = msoLineSolid
sh.Line.Style = msoLineSingle
sh.Line.Transparency = 0#
sh.Line.Visible = msoFalse
sh.LockAspectRatio = msoTrue
sh.PictureFormat.Brightness = 0.5
sh.PictureFormat.Contrast = 0.5
sh.PictureFormat.ColorType = msoPictureAutomatic
sh.PictureFormat.CropLeft = 0#
sh.PictureFormat.CropRight = 0#
sh.PictureFormat.CropTop = 0#
sh.PictureFormat.CropBottom = 0#
sh.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
sh.RelativeVerticalPosition = wdRelativeVerticalPositionPage
sh.Left = CentimetersToPoints(0)
sh.Top = CentimetersToPoints(0)
sh.LockAnchor = False
sh.WrapFormat.AllowOverlap = True
sh.WrapFormat.Side = wdWrapBoth
sh.WrapFormat.DistanceTop = CentimetersToPoints(0)
sh.WrapFormat.DistanceBottom = CentimetersToPoints(0)
sh.WrapFormat.DistanceLeft = CentimetersToPoints(0)
sh.WrapFormat.DistanceRight = CentimetersToPoints(0)
sh.WrapFormat.Type = 3
sh.ZOrder 5
sh.ZOrder msoSendToBack
sh.ZOrder msoSendBehindText
end sub
--------------------------------------------------------------------
in Word 2007, setting a Shapes property take quite long.
In my sample below, executing "FormatShape" takes 20 seconds on my machine.
I do not have the exactly value but this was quite faster in Word 2003.
Any ideas why this code executes so slow in Word 2007?
Thanks,
Dieter
--------------------------------------------------------------------
Dim sh1 As Shape
Set sh1 = ActiveDocument.Shapes.AddPicture(FileName:="c:\temp\image.jpg",
LinkToFile:=True, SaveWithDocument:=False)
Call FormatShape(sh1)
--------------------------------------------------------------------
Public Sub FormatShape(sh As Shape)
sh.Fill.Visible = msoTrue
sh.Fill.Solid
sh.Fill.ForeColor.RGB = RGB(255, 255, 255)
sh.Fill.Transparency = 0#
sh.Line.Weight = 0.75
sh.Line.DashStyle = msoLineSolid
sh.Line.Style = msoLineSingle
sh.Line.Transparency = 0#
sh.Line.Visible = msoFalse
sh.LockAspectRatio = msoTrue
sh.PictureFormat.Brightness = 0.5
sh.PictureFormat.Contrast = 0.5
sh.PictureFormat.ColorType = msoPictureAutomatic
sh.PictureFormat.CropLeft = 0#
sh.PictureFormat.CropRight = 0#
sh.PictureFormat.CropTop = 0#
sh.PictureFormat.CropBottom = 0#
sh.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
sh.RelativeVerticalPosition = wdRelativeVerticalPositionPage
sh.Left = CentimetersToPoints(0)
sh.Top = CentimetersToPoints(0)
sh.LockAnchor = False
sh.WrapFormat.AllowOverlap = True
sh.WrapFormat.Side = wdWrapBoth
sh.WrapFormat.DistanceTop = CentimetersToPoints(0)
sh.WrapFormat.DistanceBottom = CentimetersToPoints(0)
sh.WrapFormat.DistanceLeft = CentimetersToPoints(0)
sh.WrapFormat.DistanceRight = CentimetersToPoints(0)
sh.WrapFormat.Type = 3
sh.ZOrder 5
sh.ZOrder msoSendToBack
sh.ZOrder msoSendBehindText
end sub
--------------------------------------------------------------------