I'm facing a strange behaviour when inserting linefeeds in shape texts in an orgchart diagramm.
When inserting standard text without linefeeds, everything runs smoothly.
But I want to insert a number of lines and as soon as I add chr(10) or vbCrLf it begins to get slow. The more linefeeds I have, the slower it gets...
I have made the following test to proof it (in order to show the effect, I build up texts with 20 lines):
(Prior to running the test I created a orgchart with a number of shapes)
Sub testTextInsert(testType As Integer)
'testType = 1 -> Test with vbCrLf
'testType = 2 -> Test without vbCrLf
Dim myTimer, timerTotal
myTimer = Timer
Dim vShp As Visio.Shape
Dim strText As String
Dim i, j
For Each vShp In ActiveDocument.Pages(1).Shapes
If vShp.OneD = False Then don't put text to connectors...
j = j + 1
myTimer = Timer
strText = ""
For i = 1 To 20
If testType = 1 Then strText = strText & vbCrLf & "Here goes some text I want to add ... Line " & i
If testType = 2 Then strText = strText & " " & "Here goes some text I want to add ... Line " & i 'space instead of linefeed
vShp.Text = strText
Debug.Print Timer - myTimer
timerTotal = timerTotal + (Timer - myTimer)
Debug.Print j; " Shapes, Average time: " & timerTotal / j & " sec"
I tested with an orgchart with 13 shapes (position shapes).
- with linefeed (vbcrlf): average time: 4.30 seconds
- without linefeed: average time: 0.34 seconds
As I have some quite complex orgcharts, the procedure takes some minutes and my customer is impatient...
Does anybody have an idea what's going on here or what I have misunderstood?
Thanks a lot!