Set obj = CreateObject(class)
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 |
---|
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:
This script starts the application creating the object (in this case a Microsoft Excel spreadsheet). Once an object is created, you refer to it in the script using the object variable you defined.
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
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
Dim oIE
Set oIE = CreateObject("InternetExplorer.Application.1")
oIE.Visible = true
oIE.Navigate "https://www.promotic.eu"