How do I set a shapesheet cell value?

C

CarlOlen

I'm trying to set the value of the "Comment" cell in the "Miscellaneous"
Section of the shapesheet for a given shape using Visual Basic. I can
correctly create the cell object and read out its contents. But when I try
to set the cell content to a new value, I get an error.

Either...
Set cellObj = shpObjSeriesElement.CellsSRC(visSectionObject, visRowMisc,
visComment)
Debug.Print cellObj.Name
Debug.Print cellObj.Formula

or...
Set cellObj = shpObjSeriesElement.CellsU("Prop.Descriptor")
Debug.Print cellObj.Name
Debug.Print cellObj.Formula

Displaying cell content works fine.

But when I try to set the cell content to something else:
cellObj.Formula = "Text String"

I get a run-time error: -2072466907 (86db0425) #NAME?

What am I doing wrong?
 
A

AlEdlund

formula that are text based require additional quote marks (you don't have
enough). Check out the the visio sdk for examples of how to code them.

al
 
D

David Parker

e.g.
cellObj.Formula = "Text String"
should be
cellObj.Formula = "=""Text String"""
 
D

David Parker

Yeah, but you can speak more than one language :)
(German is always more verbose than English!)

Chris Roth said:
For clarity, I try to not stack all those quotemarks together. I do this:

cell.Formula = Chr(34) & "Text String" & Chr(34)

or

cell.Formula = ControlChars.Quote & "Text String" & ControlChars.Quote

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 

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