title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
Characters.AddFieldEx method (Visio) |
vis_sdr.chm10251445 |
|
|
14f56159-ed60-e1cf-1c04-b789672b51ec |
06/08/2017 |
medium |
Replaces the text represented by a Characters object with a new field of the category, code, format, language ID, and calendar ID you specify.
expression.AddFieldEx (Category, Code, Format, LangID, CalendarID)
expression A variable that represents a Characters object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Category | Required | VisFieldCategories | The category for the new field. |
Code | Required | VisFieldCodes | The code for the new field. |
Format | Required | VisFieldFormats | The format for the new field. |
LangID | Optional | Long | The language to use for the new field. |
CalendarID | Optional | Long | The calendar to use for the new field. |
Nothing
Constant values for Category, Code, and Format are declared by the Visio type library in VisFieldCategories, VisFieldCodes, and VisFieldFormats respectively.
The LangID argument should be one of the standard IDs used by Windows to encode different language versions. For example, the language ID is &H0409 for the U.S. version of Microsoft Visio. To see a list of possible language IDs, search for "VERSIONINFO" in the Microsoft Platform SDK on MSDN.
The CalendarID argument should be one of the following values, which are declared in VisCellVals in the Visio type library. The default value is visCalWestern, which sets the calendar to the Western calendar.
Constant | Value | Description |
---|---|---|
visCalWestern | 0 | Western |
visCalArabicHijri | 1 | Arabic Hijiri |
visCalHebrewLunar | 2 | Hebrew Lunar |
visCalChineseTaiwan | 3 | Taiwan Calendar |
visCalJapaneseEmperor | 4 | Japanese Emperor Reign |
visCalThaiBuddhism | 5 | Thai Buddhist |
visCalKoreanDanki | 6 | Korean Danki |
visCalSakaEra | 7 | Saka Era |
visCalTranslitEnglish | 8 | English transliterated |
visCalTranslitFrench | 9 | French transliterated |
Using the AddFieldEx method is similar to clicking Field on the Insert tab and inserting any of the following categories of fields into the text:
-
Date/Time
-
Document Info
-
Geometry
-
Object Info
-
Page Info
To add a custom formula field, use the AddCustomField or AddCustomFieldU method. When you don't pass values (or pass default values) for the optional LangID and CalendarID arguments, AddFieldEx acts exactly like AddField.
The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the AddFieldEx property to format a date field in a shape. It draws a rectangle on the drawing page and then inserts a field that displays the current date in Greek, using the Western calendar.
Public Sub AddFieldEx_Example()
Dim vsoCharacters As Visio.Characters
Dim vsoShape As Visio.Shape
ActiveWindow.DeselectAll
Set vsoShape = Application.ActivePage.DrawRectangle(3, 5, 5, 3)
vsoShape.Text = "Date: "
Set vsoCharacters = vsoShape.Characters
'Set Begin property equal to End property to
'append new text to existing text.
vsoCharacters.Begin = vsoCharacters.End
'Add a field for the current date, in Greek,
'using the Western calendar and the long date format.
vsoCharacters.AddFieldEx visFCatDateTime, visFCodeCurrentDate, visFmtMsoDateLong, 1032, visCalWestern
End Sub
[!includeSupport and feedback]