Share via


AddFieldEx Method [Visio 2003 SDK Documentation]

Replaces the text represented by a Characters object with a new field of the category, code, format, language ID, and calendar ID you specify.

object**.AddFieldEx** (Category, Code, Format, [LangID], [CalendarID])

object    Required. An expression that returns a Characters object.

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.

Version added

2003

Remarks

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 Microsoft Windows to encode different language versions. For example, the language ID is &H0409 for the U.S. version of Microsoft Office 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 menu 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 do not pass values (or pass default values) for the optional LangID and CalendarID arguments, AddFieldEx acts exactly like AddField.

Example

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

Applies to | Characters object

See Also | AddCustomFieldU method | FieldCategory property | FieldCode property | FieldFormat property