Hyperlink/Row Remove Event?

A

AdamB

Does anyone know an event I can capture for when a hyperlink is removed from
a shape?

Or for that matter, any time a row is removed? I couldn't find that either,
but thought that must be there somewhere.

The evtMod + evtCell doesn't seem to catch it...I've gone through all the
events on MSDN and haven't found one that gets raised when a hyperlink is
removed.
 
A

AdamB

Thanks for trying! Hopefully someone else has run into this.

What do you mean by the last way? Check every time how? What event would you
capture?
 
A

AdamB

No, the point is I need to fire an event WHEN the hyperlink is removed.

Anyone else out there have any ideas?

Adam
 
J

JuneTheSecond

There is left a indirect way.
You are watching user defined cells named for example "User.hyperlink"
This cell has a formula for example.
User.hyperlink="http://www.visguy.com/vgforum/"
The coode is in ThisDocument module.
Option Explicit

Private WithEvents Cell As Visio.Cell
Private shp As Visio.Shape

Private Sub Document_RunModeEntered(ByVal doc As IVDocument)
Set shp = ActivePage.Shapes(1)
Set Cell = shp.Cells("User.hyperlink")
End Sub

Private Sub Cell_CellChanged(ByVal Cell As IVCell)
Dim rep As Long
Dim IRowHyp As Long
If Not shp.CellExists("Hyperlink.VisioGuy.Address", False) Then
If MsgBox("Hyperlink to Visio Guy deleted!!" & vbCrLf _
& "Do you wish to restore hyperlink?", vbYesNo) = vbYes Then
IRowHyp = shp.AddNamedRow(visSectionHyperlink, "VisioGuy", 0)
shp.Cells("Hyperlink.VisioGuy.Address").FormulaU = _
shp.Cells("User.hyperlink").FormulaU
End If
End If
End Sub

--
Best Regards.

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

JuneTheSecond

One more correction:

User.hyperlink cell must be restored.

Option Explicit

Private WithEvents Cell As Visio.Cell
Private shp As Visio.Shape

Private Sub Document_RunModeEntered(ByVal doc As IVDocument)
Set shp = ActivePage.Shapes(1)
Set Cell = shp.Cells("User.hyperlink")
End Sub

Private Sub Cell_CellChanged(ByVal Cell As IVCell)
Dim rep As Long
Dim IRowHyp As Long
If Not shp.CellExists("Hyperlink.VisioGuy.Address", False) Then
If MsgBox("Hyperlink to Visio Guy deleted!!" & vbCrLf _
& "Do you wish to restore hyperlink?", vbYesNo) = vbYes Then
IRowHyp = shp.AddNamedRow(visSectionHyperlink, "VisioGuy", 0)
shp.Cells("Hyperlink.VisioGuy.Address").FormulaU = _
shp.Cells("User.hyperlink").FormulaU
shp.Cells("User.hyperlink").FormulaU =
"Hyperlink.VisioGuy.Address"
End If
End If
End Sub

--
Best Regards.

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


:
 
A

AdamB

Can you explain why this would work?

And why is RunModeEntered needed?

I have tried adding an event sink to visEvtMod + visEvtCell, which is the
same as the CellChanged event.

However this doesn't fire when a hyperlink is removed, only when it is added
or the text in it is changed.

What does your code do differently to get around this?

Thanks,
Adam
 
J

JuneTheSecond

Hi,

RunModeEntered event is not always necessary.
You can use DocumentOpened event to define the special cell.
But RunModeEntered event is very much convinient for debug and for users'
usage.
When debugging, developer tool button trigger the events and re-define the
cell.
When user open the drawing, the events define the cell as same as
DocumentOpen events.

--
Best Regards.

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

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