If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Performance / Velocity is bad
I have a For ... Next loop in VBA which changes the text of over 1000 Shapes
(TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#2
|
|||
|
|||
Performance / Velocity is bad
how are you looping through your shapes?
al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#3
|
|||
|
|||
Performance / Velocity is bad
Hello Al Edlund,
here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#4
|
|||
|
|||
Performance / Velocity is bad
Yes, I realize.
in the String-Vector ... ....1. Komma_Shapes_Pages(i) there is the page of the shape ....2. Komma_Shapes_ID(i) there is the ID of the shape ....3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#5
|
|||
|
|||
Performance / Velocity is bad
At a minimum I'd suggest you consider two loops
dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#6
|
|||
|
|||
Performance / Velocity is bad
No, I don't need this. All the Information which pages and which shapes
should change are in the 2 string vectors 1. Komma_Shapes_Pages() 2. Komma_Shapes_ID() REDUCED example: ' ------------------------------------------------- 'Shapes on Page 1: Komma_Shapes_Pages(1) = 1 Komma_Shapes_ID(1) = 1 Komma_Shapes_Pages(2) = 1 Komma_Shapes_ID(2) = 2 .... .... 'Shapes on page 2: Komma_Shapes_Pages(800) = 2 Komma_Shapes_ID(800) = 1 .... .... ----------------------------------------------------- I don't like a loop over all pages/shapes, because only ca. 5% of all shapes should be changed. The background is a process flow diagramm with some (over 1000) text shapes with the values of the measurements of the process. The user can read a data set of measurements from the DB for these shapes. There are many other shapes like a pipe or a vessel which are static and never change. "AlEdlund" wrote: At a minimum I'd suggest you consider two loops dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#7
|
|||
|
|||
Performance / Velocity is bad
The reason I was suggesting that you move to two loops was to reduce the
amount of time that Visio has to spend moving back and forth between pages, since I don't know if you sort the pages array. al Bernd wrote: No, I don't need this. All the Information which pages and which shapes should change are in the 2 string vectors 1. Komma_Shapes_Pages() 2. Komma_Shapes_ID() REDUCED example: ' ------------------------------------------------- 'Shapes on Page 1: Komma_Shapes_Pages(1) = 1 Komma_Shapes_ID(1) = 1 Komma_Shapes_Pages(2) = 1 Komma_Shapes_ID(2) = 2 ... ... 'Shapes on page 2: Komma_Shapes_Pages(800) = 2 Komma_Shapes_ID(800) = 1 ... ... ----------------------------------------------------- I don't like a loop over all pages/shapes, because only ca. 5% of all shapes should be changed. The background is a process flow diagramm with some (over 1000) text shapes with the values of the measurements of the process. The user can read a data set of measurements from the DB for these shapes. There are many other shapes like a pipe or a vessel which are static and never change. "AlEdlund" wrote: At a minimum I'd suggest you consider two loops dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#8
|
|||
|
|||
Performance / Velocity is bad
Yes, the pages array is sorted (Komma_Shapes_Pages()).
There are no unnecessary moves between the pages. Have You an advise to faster the procedure? "AlEdlund" wrote: The reason I was suggesting that you move to two loops was to reduce the amount of time that Visio has to spend moving back and forth between pages, since I don't know if you sort the pages array. al Bernd wrote: No, I don't need this. All the Information which pages and which shapes should change are in the 2 string vectors 1. Komma_Shapes_Pages() 2. Komma_Shapes_ID() REDUCED example: ' ------------------------------------------------- 'Shapes on Page 1: Komma_Shapes_Pages(1) = 1 Komma_Shapes_ID(1) = 1 Komma_Shapes_Pages(2) = 1 Komma_Shapes_ID(2) = 2 ... ... 'Shapes on page 2: Komma_Shapes_Pages(800) = 2 Komma_Shapes_ID(800) = 1 ... ... ----------------------------------------------------- I don't like a loop over all pages/shapes, because only ca. 5% of all shapes should be changed. The background is a process flow diagramm with some (over 1000) text shapes with the values of the measurements of the process. The user can read a data set of measurements from the DB for these shapes. There are many other shapes like a pipe or a vessel which are static and never change. "AlEdlund" wrote: At a minimum I'd suggest you consider two loops dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#9
|
|||
|
|||
Performance / Velocity is bad
Based on that it sounds like you already have done what needs to be
accomplished, :-( al Bernd wrote: Yes, the pages array is sorted (Komma_Shapes_Pages()). There are no unnecessary moves between the pages. Have You an advise to faster the procedure? "AlEdlund" wrote: The reason I was suggesting that you move to two loops was to reduce the amount of time that Visio has to spend moving back and forth between pages, since I don't know if you sort the pages array. al Bernd wrote: No, I don't need this. All the Information which pages and which shapes should change are in the 2 string vectors 1. Komma_Shapes_Pages() 2. Komma_Shapes_ID() REDUCED example: ' ------------------------------------------------- 'Shapes on Page 1: Komma_Shapes_Pages(1) = 1 Komma_Shapes_ID(1) = 1 Komma_Shapes_Pages(2) = 1 Komma_Shapes_ID(2) = 2 ... ... 'Shapes on page 2: Komma_Shapes_Pages(800) = 2 Komma_Shapes_ID(800) = 1 ... ... ----------------------------------------------------- I don't like a loop over all pages/shapes, because only ca. 5% of all shapes should be changed. The background is a process flow diagramm with some (over 1000) text shapes with the values of the measurements of the process. The user can read a data set of measurements from the DB for these shapes. There are many other shapes like a pipe or a vessel which are static and never change. "AlEdlund" wrote: At a minimum I'd suggest you consider two loops dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
#10
|
|||
|
|||
Performance / Velocity is bad
anyway thanks for your efforts
Bernd "AlEdlund" wrote: Based on that it sounds like you already have done what needs to be accomplished, :-( al Bernd wrote: Yes, the pages array is sorted (Komma_Shapes_Pages()). There are no unnecessary moves between the pages. Have You an advise to faster the procedure? "AlEdlund" wrote: The reason I was suggesting that you move to two loops was to reduce the amount of time that Visio has to spend moving back and forth between pages, since I don't know if you sort the pages array. al Bernd wrote: No, I don't need this. All the Information which pages and which shapes should change are in the 2 string vectors 1. Komma_Shapes_Pages() 2. Komma_Shapes_ID() REDUCED example: ' ------------------------------------------------- 'Shapes on Page 1: Komma_Shapes_Pages(1) = 1 Komma_Shapes_ID(1) = 1 Komma_Shapes_Pages(2) = 1 Komma_Shapes_ID(2) = 2 ... ... 'Shapes on page 2: Komma_Shapes_Pages(800) = 2 Komma_Shapes_ID(800) = 1 ... ... ----------------------------------------------------- I don't like a loop over all pages/shapes, because only ca. 5% of all shapes should be changed. The background is a process flow diagramm with some (over 1000) text shapes with the values of the measurements of the process. The user can read a data set of measurements from the DB for these shapes. There are many other shapes like a pipe or a vessel which are static and never change. "AlEdlund" wrote: At a minimum I'd suggest you consider two loops dim intPage as integer dim intShape as integer for intPage = 1 to page count for intShape to shapes on page count next intshape next intpage al Bernd wrote: Yes, I realize. in the String-Vector ... ...1. Komma_Shapes_Pages(i) there is the page of the shape ...2. Komma_Shapes_ID(i) there is the ID of the shape ...3. Komma_Shapes_Inhalt(i) there is the new text content for the shape The first and the second vector I compute at the start of the document (only one-time). The time for that is not important for me. Before the loop the content of the third string vector is computing. The time for that is not more then 1 second. The problem is the loop (about 13seconds). This operation is often doing by user. Loop: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: you do realize that you are using the integer value (i) for both the page and the shape array pointer within the page, right ? al "Bernd" wrote in message ... Hello Al Edlund, here the extraction of VBA: For i = 1 To UBound(Komma_Shapes_ID) ThisDocument.Pages(Komma_Shapes_Pages(i)).Shapes.I temFromID(Komma_Shapes_ID(i)).Text = Komma_Shapes_Inhalt(i) Next i "AlEdlund" wrote: how are you looping through your shapes? al "Bernd" wrote in message ... I have a For ... Next loop in VBA which changes the text of over 1000 Shapes (TextShapes). The time for that is about 13 seconds. My processor is working with 25%. Is it possible to save time? Some commands I tried (before the For-Next-Loop), but it is not faster: Application.PurgeUndo Application.UndoEnabled = False Application.ScreenUpdating = False Application.ShowChanges = False Application.ShowProgress = False Application.DeferRecalc = False Application.LiveDynamics = False |
Thread Tools | |
Display Modes | |
|
|