Thread: [Solved] VBA and shapes very slow
View Single Post
 
Old 02-15-2016, 08:07 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,387
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmaxey View Post
This is a strange issue that I am certainly unable to explain.
Likewise.

However, given that the code works much better with a new document, perhaps the following could serve as the basis for a workaround:
Code:
Sub MesureDureebis()
Application.ScreenUpdating = False
Dim i As Long, Boite As Shape, Debut As Date, DocTmp As Document, Rng As Range
Debut = Time
Set Rng = Selection.Range
Set DocTmp = Documents.Add
With DocTmp
  For i = 1 To 500
    Set Boite = .Shapes.AddShape(msoShapeRectangle, 4 * i, 72.75, 4, 19.5)
    Boite.Fill.ForeColor.RGB = RGB(2 * i, 2 * i, 2 * i)
  Next i
  Rng.FormattedText = .Range.FormattedText
  .Close False
End With
Application.ScreenUpdating = True
MsgBox CStr((Time - Debut) * 24 * 3600) & " s"
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote