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
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