Microsoft Word System Object a complete reference VBA example

Microsoft Word System Object a complete reference VBA example

System

Is a Word object which offers Machine and Operating System level properties and methods which helps user to identify current environment. A System object helps to determine current platform, connect to external or password protected drive etc.

Code example

Public Sub SystemObject()
    'connect to a path
    If InStr(1, System.OperatingSystem, "Windows") > 0 Then
        'Correnct
        System.Connect Path = "\\Drive Path", Password:="password"
    End If
    
    With System
        'Check Country region
        Select Case .CountryRegion
            Case wdArgentina:
                Debug.Print "Your Country Region is Argentina"
            Case wdBrazil:
                Debug.Print "Your Country Region is Brazil"
            Case wdCanada:
                Debug.Print "Your Country Region is Canada"
            Case wdChile:
                Debug.Print "Your Country Region is Chile"
            Case wdChina:
                Debug.Print "Your Country Region is China"
            Case wdDenmark:
                Debug.Print "Your Country Region is Denmark"
            Case wdFinland:
                Debug.Print "Your Country Region is Finland"
            Case wdFrance:
                Debug.Print "Your Country Region is France"
            Case wdGermany:
                Debug.Print "Your Country Region is Germany"
            Case wdIceland:
                Debug.Print "Your Country Region is Iceland"
            Case wdItaly:
                Debug.Print "Your Country Region is Italy"
            Case wdJapan:
                Debug.Print "Your Country Region is Japan"
            Case wdKorea:
                Debug.Print "Your Country Region is Korea"
            Case wdLatinAmerica:
                Debug.Print "Your Country Region is Latin America"
            Case wdMexico:
                Debug.Print "Your Country Region is Mexico"
            Case wdNetherlands:
                Debug.Print "Your Country Region is Netherlands"
            Case wdNorway:
                Debug.Print "Your Country Region is Norway"
            Case wdPeru:
                Debug.Print "Your Country Region is Peru"
            Case wdSpain:
                Debug.Print "Your Country Region is Spain"
            Case wdSweden:
                Debug.Print "Your Country Region is Sweden"
            Case wdTaiwan:
                Debug.Print "Your Country Region is Taiwan"
            Case wdUK:
                Debug.Print "Your Country Region is United Kingdom"
            Case wdUS:
                Debug.Print "Your Country Region is United States"
            Case wdVenezuela:
                Debug.Print "Your Country Region is Venezuela"
        End Select
        
        'Change cursor to Beam
        .Cursor = wdCursorIBeam
        'Northwest arrow
        .Cursor = wdCursorNorthwestArrow
        'Wait
        .Cursor = wdCursorWait
        'Normal
        .Cursor = wdCursorNormal
        
        'Check if less than 20mb space
        If (.FreeDiskSpace \ 1048576) < 20 Then
            Debug.Print "You are running out of space"
        End If
        'Resolution
        Debug.Print "Horizontal Resolution of your Screen : " & .HorizontalResolution
        Debug.Print "Vertical Resolution of your Screen : " & .VerticalResolution
        'Language
        Debug.Print "System Language detected : " & .LanguageDesignation
        'Math co processor
        Debug.Print "You system has Math Co-Processor Installed on your system " & .MathCoprocessorInstalled
        'OS Name
        Debug.Print "You have "; .OperatingSystem & " Operating System"
        'OS Version
        Debug.Print .Version
    End With
End Sub

Output

Your Country Region is United States
Horizontal Resolution of your Screen : 1366
Vertical Resolution of your Screen : 768
System Language detected : English (United States)
You system has Math Co-Processor Installed on your system True
You have Windows NT Operating System
6.1

Next>> Find Complete System Information using VBA

Leave a Reply

Your email address will not be published.