Why will this code work stepping through but not in window

E

Edward

Using Visio 2002 I have written a search facility in VB to locate shapes on
drawings, hyperlink to the drawing and select the shape, and that works fine.

But I want to make the selection more obvious by changing the height and
width, alternating between its original value and increasing it by a factor
of 2 for a number of seconds.

The code shown below works perfectly only if I step through the VB code. If
I let it run, the delay takes place but nothing in the Visio window changes.

The code is below; ignore the commented out For..Next loop, I replaced it
with a Do loop to see if that was it and it wasn't...

----------------------------------------------------
Set sobj = ActiveWindow.Page.Shapes(sname)
ActiveWindow.Select sobj, visDeselectAll + visSelect
Dim owidth, oheight As Double, flashcount As Integer
With sobj
owidth = sobj.Cells("width").Result("mm")
oheight = sobj.Cells("height").Result("mm")
' For flashcount = 1 To 10
flashcount = 1
Do Until flashcount = 10
If flashcount / 2 - Int(flashcount / 2) = 0 Then ' even number
.Cells("width").FormulaForceU = "=" & owidth & "mm"
.Cells("height").FormulaForceU = "=" & oheight & "mm"
Else
.Cells("width").FormulaForceU = "=" & owidth * 2 & "mm"
.Cells("height").FormulaForceU = "=" & oheight * 2 & "mm"
End If
Delay 1
flashcount = flashcount + 1
Loop
' Next
.CellsSRC(visSectionObject, visRowXFormOut,
visXFormWidth).FormulaForceU = "=" & owidth & "mm"
.CellsSRC(visSectionObject, visRowXFormOut,
visXFormHeight).FormulaForceU = "=" & oheight & "mm"
End With


Sub Delay(interval)
' Kills time for specified interval in seconds
Dim timenow As Long
timenow = Timer
Do Until Timer - timenow > interval
Loop
End Sub
 
A

AlEdlund

within your timer loop you should put a 'doevents' statement so that it will
yield cycles to the other processes (like screen updating, cell traversals,
etc.).
al
 
E

Edward

Thanks so much Al, I wish I'd asked sooner. It's perfect now!!
--
Ted Keating


AlEdlund said:
within your timer loop you should put a 'doevents' statement so that it will
yield cycles to the other processes (like screen updating, cell traversals,
etc.).
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VB to set image setting 2

Top