PDA

View Full Version : Application object names, true, false etc



theta
04-23-2013, 06:38 AM
When working with object names, properties, logical statement you sometimes need to check the returned value (or a string).

When moving between different version of Excel (English, German, French) this can change e.g.

Class becomes Klasse
True becomes Wahr
False becomes Falsh
Worksheet becomes Werkblad
Workbook becomes Werkboek

Is there a way to get the application name for an object, property or type ? e.g.

Application True = "Wahr"
Application Workbook = "Werkboek"

This would allow me to use application default named instead of hard coding references. Real world example :



If vc.Type = 100 Then c00 = IIf(vc.Properties.Count = 66, "werkblad", "werkboek")

Paul_Hossler
04-23-2013, 06:43 AM
TypeName might help a little



Returns a String that provides information about a variable (http://vbaexpress.com/forum/ms-help://MS.EXCEL.DEV.12.1033/EXCEL.DEV/content/HV01200929.htm).
Syntax
TypeName(varname)
The required varname argument (http://vbaexpress.com/forum/ms-help://MS.EXCEL.DEV.12.1033/EXCEL.DEV/content/HV01200929.htm) is a Variant (http://vbaexpress.com/forum/ms-help://MS.EXCEL.DEV.12.1033/EXCEL.DEV/content/HV01200929.htm) containing any variable except a variable of a user-defined type (http://vbaexpress.com/forum/ms-help://MS.EXCEL.DEV.12.1033/EXCEL.DEV/content/HV01200929.htm).


I don't know how 'International' it is (no way to test), but may be it returns the 'local' name.

Even if it always returns the 'English' name you might be able to program around that

Good luck

Paul

Aflatoon
04-23-2013, 06:56 AM
This is not usually an issue in VBA. True is True as far as VBA is concerned unless you coerce it to a string before testing and I don't know why you would do that?

snb
04-23-2013, 06:57 AM
In VBA retruned values are always in American English.

The code you showed is meant to return a language specific string; not a result of any VBA code/property/value.

theta
04-23-2013, 07:03 AM
Thanks snb. I am looking through that tool you uploaded on the seperate thread about building a call tree.

I am updating it to English, and I have several other projects with similar issues. So thought I would ask about international settings and detecting names of objects.