Visual Basic Equivalents C

Microsoft Word Visual Basic

Visual Basic Equivalents C

   

ABCDEFGHIJKLMNOPRSTUVWY

C  
Call Call

' or

WordBasic.Call

' or

Application.Run

Cancel Selection.ColumnSelectMode = False

Selection.ExtendMode = False

Selection.EscapeKey

CancelButton CommandButton
CenterPara, CenterPara() Selection.Paragraphs.Alignment = wdAlignParagraphCenter

x = Selection.Paragraphs.Alignment

ChangeCase, ChangeCase() Selection.Range.Case = WdCharacterCase

x = Selection.Range.Case

CharColor, CharColor() Selection.Font.ColorIndex = WdColorIndex

x = Selection.Font.ColorIndex

CharLeft 1

CharLeft 1, 1

num = CharLeft(1)

Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdMove

Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

num = Selection.MoveLeft(Unit:=wdCharacter, Count:=1)

CharRight 1

CharRight 1, 1

num = CharRight(1)

Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove

Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend

num = Selection.MoveRight(Unit:=wdCharacter, Count:=1)

ChDefaultDir path, wdDefaultFilePath Options.DefaultFilePath(WdDefaultFilePath) = path
ChDir path ChDir path

' or

Application.ChangeFileOpenDirectory

CheckBox CheckBox control
CheckBoxFormField ActiveDocument.FormFields.Add Range:=range, Type:=wdFieldFormCheckBox
ChooseButtonImage With CommandBars(name).Controls(1)

    .FaceId = num

    .TooltipText = text

End With

Chr$(num) Chr(num)
CleanString$(string) x = CleanString(string)
ClearAddInst Addins.Unload
ClearFormField ActiveDocument.FormFields(1).TextInput.Clear
Close Close
ClosePane ActiveWindow.ActivePane.Close
ClosePreview ActiveDocument.ClosePrintPreview
CloseUpPara Selection.Paragraphs.CloseUp
CloseViewHeaderFooter ActiveWindow.View.SeekView = wdSeekMainDocument
CmpBookmarks() If ActiveDocument.Bookmarks(name) = ActiveDocument.Bookmarks(name) Then

    same = True

End If

The Start and End properties can be used to compare the starting and ending positions of two bookmarks.

ColumnSelect Selection.ColumnSelectMode = True
ComboBox ComboBox control
CommandValid() Use the IsObjectValid property to determine if an object variable reference is valid. Also an object variable that returns Nothing is not valid.
Connect System.Connect
ControlRun WordBasic.ControlRun

' or

Shell appfilename

Converter$(num) x = FileConverters(num).ClassName
ConverterLookup(name) x = FileConverters(name).SaveFormat
ConvertObject IconNumber, ActivateAs, IconFileName, Caption, Class, DisplayIcon With ActiveDocument.Shapes(1).OLEFormat

    .IconIndex = num

    .ActivateAs = text

    .IconPath & Application.PathSeparator & .IconName

    .IconLabel = text

    .ClassType = text

    .DisplayAsIcon = True

End With

CopyBookmark ActiveDocument.Bookmarks(name).Copy(name)
CopyButtonImage CommandBars(name).Controls(1).CopyFace
CopyFile FileCopy
CopyFormat Selection.CopyFormat
CopyText Application.Run MacroName:="CopyText"
CountAddins() x = Addins.Count
CountAutoCorrectExceptions(0)

CountAutoCorrectExceptions(1)

x = AutoCorrect.FirstLetterExceptions.Count

x = AutoCorrect.TwoInitialCapsExceptions.Count

CountAutoTextEntries() x = ActiveDocument.AttachedTemplate.AutoTextEntries.Count
CountBookmarks() x = ActiveDocument.Bookmarks.Count
CountDirectories() myPath = "C:\"

myName = Dir(myPath, vbDirectory)

Do While myName <> ""

    If myName <> "." And myName <> ".." Then

        If (GetAttr(myPath & myName) And vbDirectory) = vbDirectory Then

            count = count + 1

        End If

    End If

myName = Dir

Loop

MsgBox count & " directories"

CountDocumentProperties() x = ActiveDocument.BuiltInDocumentProperties.Count

' or

x = ActiveDocument.CustomDocumentProperties.Count

CountDocumentVars() x = ActiveDocument.Variables.Count
CountFiles() x = RecentFiles.Count
CountFonts() x = FontNames.Count

' or

x = PortraitFontNames.Count

' or

x = LandscapeFontNames.Count

CountFoundFiles() x = Application.FileSearch.FoundFiles.Count
CountKeys() CustomizationContext = template or document

x = KeyBindings.Count

CountLanguages() x = Languages.Count
CountMacros() ' no direct equivalent

' counts the number of modules associated with the normal template

For Each xItem In NormalTemplate.VBProject.VBComponents

    If xItem.Type = vbext_ct_StdModule Then Count = Count + 1

Next x

MsgBox Count

CountMenuItems() x = CommandBars(name).Controls.Count
CountMenus() x = CommandBars.ActiveMenuBar.Controls.Count
CountMergeFields() x = ActiveDocument.MailMerge.Fields.Count
CountStyles() x = ActiveDocument.Styles.Count

' or

x = ActiveDocument.AttachedTemplate.OpenAsDocument.Styles.Count

' to exclude built-in styles from the count

For Each xSty In ActiveDocument.Styles

    If xSty.BuiltIn = False Then aCount = aCount + 1

Next xSty

CountToolbarButtons() x = CommandBars(name).Controls.Count
CountToolbars() For Each xCB In CommandBars

    If xCB.Type = msoBarTypeNormal Then aCount = aCount + 1

Next xCB

CountToolsGrammarStatistics() x = ActiveDocument.Content.ReadabilityStatistics.Count
CountWindows() x = Windows.Count
CreateSubdocument ActiveDocument.Subdocuments.AddFromRange