I need help with manipulating shapes from code!

J

Joseph Burton

I need help. Maybe what I trying to do is not possible.

I have some objects on a drawing and I figured out how to reference them in
code by using the visio type library.
Well what I want to be able to do is change the background or foreground
color of the shapes in code.

I'm using cellObj.Formula = "5", to change the foreground to yellow, but
nothing happens.

What am I doing wrong?

Dim appVisio As Visio.Application
Dim docsObj As Visio.Documents
Dim docObj As Visio.Document
Dim pagsObj As Visio.Pages
Dim pagObj As Visio.Page
Dim shpObj As Visio.Shape
Dim cellObj As Visio.Cell


Dim sectionObj, rowFill, fillForeGround As Short

sectionObj = CInt(Visio.VisSectionIndices.visSectionObject)
rowFill = CInt(Visio.VisRowIndices.visRowFill)
fillForeGround = CInt(Visio.VisCellIndices.visFillForegnd)

'Create an instance of Visio and create a document based on the Basic
'Diagram template. It doesn't matter if an instance of Visio is
already running;
'the program will run a new one.
appVisio = CType(CreateObject("Visio.Application"), Visio.Application)
docsObj = appVisio.Documents
docsObj.Open("C:\Documents and
Settings\joeburton\Desktop\JoeDrawing.vsd")

pagsObj = appVisio.ActiveDocument.Pages
pagObj = pagsObj.Item(1)

'point to shape
shpObj = pagObj.Shapes.Item("JoJoPointer")
cellObj = shpObj.CellsSRC(sectionObj, rowFill, fillForeGround)
cellObj.Formula = "5"


docObj.SaveAs("C:\Documents and
Settings\joeburton\Desktop\JoeDrawing.vsd")
MsgBox("Finished!")
appVisio.Quit()
 
J

Joseph Burton

I'm guessing its a simple object. It's the only object on the diagram at the
moment.
 

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