Promotic
WikipediaLinkedInYoutubeTwitterFacebook

CreateObject - function of language VBScript

Description:
Creates and returns a reference to an Automation object.
Syntax:
CreateObject(class As Variant) As Object
Calling:
Set o = CreateObject(class)
Parameters:
class(Variant) uses the syntax ServerName.TypeName:
ServerName - The name of the application providing the object
TypeName - The type or class of the object to create
Note:

Automation servers provide at least one type of object. For example, a word-processing application may provide an application object, a document object and a toolbar object.

To create an Automation object, assign the object returned by CreateObject to an object variable:

Dim oExcel
Set oExcel = CreateObject("Excel.Sheet")

This code starts the application creating the object (in this case, a Microsoft Excel spreadsheet). Once an object is created, you refer to it in code using the object variable you defined.

Example1:
Creation of file Test.xls by means of program EXCEL
Dim oExcelApp, oWorkbook, oSheet
Set oExcelApp = CreateObject("Excel.Application")
oExcelApp.Visible=true
Set oWorkbook = oExcelApp.WorkBooks.Add
Set oSheet = oExcelApp.Sheets(1)
oSheet.Cells(1,1) = oWorkbook.Sheets.Count
oSheet.Cells(1,2) = 34
oSheet.Cells(2,1) = Now
oSheet.SaveAs "C:\Data\Test.xls"
oExcelApp.Quit
Example2:
Creation of file Test.doc by means of program WORD
Dim oWord
Set oWord = CreateObject("Word.Basic")
oWord.AppShow
oWord.FileOpen "C:\Data\Test.doc"
oWord.Insert "" & vbNewLine
oWord.Insert "Temperature=" & pMe.Pm("/Kogen/Temp").Value & " °C " & vbNewLine
oWord.FileSave
Example3:
Launch the IE browser with specified web address
Dim oIE
Set oIE = CreateObject("InternetExplorer.Application.1")
oIE.Visible = true
oIE.Navigate "http://www.promotic.eu"
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice