Use of function .Cells and .CellsSRC with Visio and VB

F

Fred

I'm using the custom properties section to store data from a Access Database.
When I try to retrieve that data with a vb program using either .Cells or
..CellsSRC I am only succesfull if the value field of the cust prop has a
number (integer or real) in it. If the value is a string, both functions
return a zero.

prop.input1.value = 13 ...... both functions return 13
prop.input1.value = XSEL ... both functions return 0


Any ideas?

Thanks
 
M

Mark Nelson [MS]

Cells and CellsSRC are methods that return a Cell object, not a value. The
Cell object has a ResultIU property which is designated as the default
property for the object. Thus when you get a result from .Cells(cellName)
you are really getting .Cells(cellName).ResultIU. This property returns a
numeric value converted to Internal Units (typically inches).

You can retrieve a string from a cell by accessing the ResultStr property on
the Cell object. ResultStr requires a parameter specifying the units that
the string value should be converted to. For example,
..Cells(cellName).ResultStr(visFeet) would return a string value with feet
units: "3.15 ft." For strings that have nothing to do with unit-ed values,
use 0. For example, .Cells(cellName).ResultStr(0) might return a string
like "Apple".

To assign a string to a cell, it is generally best to use the Formula
property on the Cell. Strings assigned as formulas must be enclosed in
quotation marks. To avoid confusion with the quotation marks that you wrap
strings in the VB editor with to identify them as strings, use Chr(34) to
represent a quotation mark. For example, .Cells(cellName).Formula = "=" +
Chr(34) + "Apple" + Chr(34) would assign the string value 'Apple' to the
cell.
 

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