strings in formulas

V

Vera

in vba, I have a string variable the value of which I'd like to assign to a
shape cell. When the string variable has a numerical value I can assign the
value to the cell okay, but when the string value has alpha characters it
doesn't work. Can you help? Thanks (as always!), vera
 
P

Paul Herber

in vba, I have a string variable the value of which I'd like to assign to a
shape cell. When the string variable has a numerical value I can assign the
value to the cell okay, but when the string value has alpha characters it
doesn't work. Can you help? Thanks (as always!), vera

To which cell are you assigning this variable?
 
V

Vera

The cell I'm writing to is: CellsSRC(visSectionUser, 0, visUserValue) on the
document shape sheet. The variable is a string myBusinessObjectsList and its
values is a text list of business object names. The """"" solution doesn't
seem to work. Thanks, thanks, vera
 
V

Vera

Application.ActiveWindow.Shape.CellsSRC(visSectionUser, 0,
visUserValue).FormulaU = myBusinessObjectList
If the value of myBusinessObjectList (a string) is numerical, it works. If
it's text, it doesn't. I'm so puzzled! thanks so much, vera
 
J

John Marshall, MVP

For numeric values, there is no issue, but with strings you need quotes.
Since the quotes are stripped off as the string is processed, you need more
than a single set of quotes. In this case, you need four quotes before and
after the string. Why four? The outside ones indicate that this is a string
and the inner one tells the string processor that you mean the character is
a quote rather tan te end of the string.

In your reply you indicate five quotes.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
Visio Wishlist http://www.mvps.org/visio/wish_list.htm
 
M

Mark Nelson [MS]

One way to avoid going quote crazy is to use the CHR function.

CellsU("User.MyUserCell").FormulaU = "=" + Chr(34) + "My string value" +
Chr(34)


--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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