Cannot get cells to update after dropping a master thru code

C

Carl

Hello,
I have some VB6 code in an ActiveX dll running inside a VSL wrapper. This
code goes through a loop, calling a function that drops a master on the page
in each loop. After dropping the master the function updates the text in one
cell while another cell recalculates the shape height using the TEXTHEIGHT()
function. My function then returns a reference to the new shape to the main
loop. I use that shape reference to read the .Cells("Height") to do further
processing.

Unfortunately, the height value returned is the height of the shape when it
was initially dropped on the page, not the recalculated height. I can see
the height has changed by looking at the shape on the page, but the height
returned to my code doesn't get updated. I've tried different thngs such as
the cell.trigger to try force a recalc with no luck. The shape appears not
to trigger a recalc until I exit the loop. I've tried looking at the
CellChanged event and even have tried to release the shape reference and get
a new one but it still won't return the new height. It seems to que up the
events until the loop is finished even with a DoEvents in the loop.

Is there any way to do this?

Thanks, Carl
 
C

Carl

Thanks for the reply June,
But, changing the local master won't help as each shape has a height
property that may change after the drop event is completed and that height
will vary shape to shape depending on the formula's recalc. It is this value
after all the recalcs are done that I'm trying to get for each indiviual
shape.

Carl
 
C

Carl

Here's some psuedo code:

Main routine:
dim MyShape as visio.shape

for iloop = 1 to iNumRows
set MyShape = InsertLineItem(sMasterName, sText, etc..)

'do something with the new height
MyVar = MyShape.Cells("Height")
next


function InsertLineItem (byval strStnSource as string, byval sText as
string, etc..) as visio.shape
dim shpNewLineItem as visio.shape

'find the master
Set objStnSource = glo.VisioApp.Documents(strStnSource).Masters
Set masLineItem = objStnSource(strLineItemMaster)

'drop the master into our group shape
Set shpNewLineItem = shpParentGroup.Drop(masLineItem, 0, 0)

'adjust the shape height
shpNewLineItem.Cells("User.fCol5").ResultU = sText
shpNewLineItem.Cells("Height").ResultU = "=TEXTHEIGHT(fCol5)

'adjust the position, pinx and piny, etc...

end function

When I check MyShape.Cells("Height") it never gets the newly calculated
value, it is always the original height of the master.

thanks, carl
 
P

Paul Herber

Hello,
I have some VB6 code in an ActiveX dll running inside a VSL wrapper. This
code goes through a loop, calling a function that drops a master on the page
in each loop. After dropping the master the function updates the text in one
cell while another cell recalculates the shape height using the TEXTHEIGHT()
function. My function then returns a reference to the new shape to the main
loop. I use that shape reference to read the .Cells("Height") to do further
processing.

Unfortunately, the height value returned is the height of the shape when it
was initially dropped on the page, not the recalculated height. I can see
the height has changed by looking at the shape on the page, but the height
returned to my code doesn't get updated. I've tried different thngs such as
the cell.trigger to try force a recalc with no luck. The shape appears not
to trigger a recalc until I exit the loop. I've tried looking at the
CellChanged event and even have tried to release the shape reference and get
a new one but it still won't return the new height. It seems to que up the
events until the loop is finished even with a DoEvents in the loop.

Is there any way to do this?

Check that you haven't got the LockCalcWH flag set
(Shape sheet Protection section)
 
J

JuneTheSecond

Hi,

I think key point may be in your last 2 lines.
'adjust the shape height
shpNewLineItem.Cells("User.fCol5").ResultU = sText
shpNewLineItem.Cells("Height").ResultU = "TEXTHEIGHT(fCol5)"

Though I cannot see the true text in the sText,
I think TEXTHEIGHT function needs one more arguments.

--
Best Regards.

JuneTheSecond
Now, visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html
 
J

JuneTheSecond

Hi,

I am sorry to late, but now I understand your situation.

User QueueMarkerEvent method and MarkerEvent events.
Add QueueMarkerEvent at the last of your code.

'do something with the new height
MyVar = MyShape.Cells("Height")
myApp.QueueMarkerEvent "Dummy"

And make MarkerEvent for example.

Private Sub myApp_MarkerEvent(ByVal app As IVApplication, _
ByVal SequenceNum As Long, ByVal ContextString As String)
Debug.Print MyShape.Cells("Height")
End Sub

--
Best Regards.

JuneTheSecond
Now, visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html


:
 
J

JuneTheSecond

Or,

Pass only MyShape name to the Marker event las follows.

'do something with the new height
MyVar = MyShape.Cells("Height")
myApp.QueueMarkerEvent MyShape.NameU
Next

And get height like,,,

Private Sub myApp_MarkerEvent(ByVal app As IVApplication, _
ByVal SequenceNum As Long, ByVal ContextString As String)
Debug.Print shpParentGroup.Shapes(ContextString).Cells("Height")
End Sub

--
Best Regards.

JuneTheSecond
Now, visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html
 
C

Carl

Hi June,
Thanks for the idea. I will give that a go. I will test this when I get a
chance. The other events such as CellChanged never seemed to fire until you
are out of the loop, but I'll give it a go.

Carl
 
C

Carl

Hi Paul,
Yes that was one of the first things I checked. The shape itself does
actually resize after all is said and done, but it seems returning that new
height thru code is problematic.

I'm going to play with the Marker event as suggested by June.

Thanks, Carl
 

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

Top