imported image & Shape ScreenTip

B

booner

I see how I can programmatically import an image onto a visio document (very
cool).

I would like to also associate a shape screentip with that shape (think
tooltip - to help them understand the image). The import returns me a visio
shape - but I do not see a way to associate the screentip with the shape.

I've recorded a macro but the code - makes no sense to me - i.e. how I can
do that programmatically.

Many thanks.
 
J

John Goldsmith

Hello Booner,

Have a go with this:

Sub AddNewImageWithComment()
Dim shp As Visio.Shape

Set shp = ActivePage.Import("C:\MyImage.jpg")
shp.CellsSRC(visSectionObject, visRowMisc, visComment).FormulaU = "My
new image"

End Sub

Best regards

John


John Goldsmith
www.visualSignals.co.uk
 
B

booner

Very similar to what I see when I record a macro.

However ... in VB.Net - visSectionObject, visRowMisc, visComment) are not
defined.

So not sure what CellsSRC does ... I just declare these variables.

When that line runs in Visual Studio - get COMException #NAME?

Any ideas?
 
B

booner

Alright - had a duh moment. Noticed later - those variables are constants
.... tried that ... get the same COMException.

In VB.NET

Dim vApp As Visio.Application
Dim vDoc As Visio.Document

vApp = New Visio.InvisibleApp()

vDoc = vApp.Documents.Add("")

Dim shape As Visio.Shape
shape = vApp.ActivePage.Import("image.jpg")
shape.CellsSRC(Visio.VisSectionIndices.visSectionObject, _
Visio.VisRowIndices.visRowMisc, _
Visio.VisCellIndices.visComment).FormulaU = "my
image"

Last line is where I get the COMException.
 
D

David Parker

You need to enter text within double-double quotes, otherwise Visio assumes
you are entering a formula
e.g.
shape.CellsSRC(Visio.VisSectionIndices.visSectionObject, _
Visio.VisRowIndices.visRowMisc, _
Visio.VisCellIndices.visComment).FormulaU = "=""my
image"""
 

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