⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbs83.htm

📁 VBScript 是一种脚本语言
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML><HEAD><TITLE>CreateObject Function</TITLE> 
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="PRODUCT" CONTENT="Visual Basic Scripting Edition">
<META NAME="TECHNOLOGY" CONTENT="SCRIPTING">
<META NAME="CATEGORY" CONTENT="Language Reference">

<META NAME="Keywords" CONTENT="objects,;CreateObject function,;object variable,;creating objects,;objects, creating,;variables, object,;creating OLE Automation objects,;OLE Automation objects, creating,;variables,;OLE Automation objects,"><META NAME="Description" CONTENT="CreateObject Function"></HEAD>

<BODY BGCOLOR=FFFFFF LINK=#0033CC>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR VALIGN=TOP><TD WIDTH=360>
<FONT SIZE=1 COLOR=#660033>Microsoft&#174; Visual Basic&#174; Scripting Edition</FONT><BR>
<FONT SIZE=5 COLOR=#660033><B>
CreateObject Function</B></FONT>

</TD>
<TD ALIGN=RIGHT>
<FONT SIZE=2>&nbsp;<A HREF="vbstoc.htm">Language&nbsp;Reference</A>&nbsp;<BR>
<A HREF="vbs16.htm">Version&nbsp;2</A>&nbsp;<P></FONT>
</TD></TR>
</TABLE> 
<FONT SIZE=2><P>
<A HREF="vbs84.htm">See Also</A></FONT>
<HR noshade SIZE=1>

<H5>Description</H5>
<BLOCKQUOTE>Creates and returns a reference to an <a href="vbs0.htm#defOLEAutomationObject">Automation object</a>.</BLOCKQUOTE>

<H5>Syntax</H5>
<BLOCKQUOTE><b>CreateObject(</b><i>class</i><b>)</b><P>
The <i>class</i> argument uses the syntax <i>servername.typename</I> and has these parts: <P>

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>

<TR VALIGN=TOP BGCOLOR="#DDDDDD">
	<TD><FONT SIZE=2><b>Part</b></FONT></TD>
		<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>

<TR VALIGN=TOP>
	<TD><FONT SIZE=2><i>servername</i></FONT></TD>
		<TD><FONT SIZE=2>The name of the application providing the object.</FONT></TD></TR>

<TR VALIGN=TOP>
	<TD><FONT SIZE=2><i>typename</i></FONT></TD><TD><FONT SIZE=2>The type or class of the object to create.</FONT></TD></TR></TABLE></BLOCKQUOTE>

<H5>Remarks</H5>
<BLOCKQUOTE>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.<P>

To create an Automation object, assign the object returned by <b>CreateObject</b> to an object variable:
<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>Dim ExcelSheet
Set ExcelSheet = <FONT COLOR="#FF0000">CreateObject(</FONT>"Excel<FONT COLOR="#FF0000">.</FONT>Sheet"<FONT COLOR="#FF0000">)</FONT>
</FONT></PRE>
</BLOCKQUOTE>
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. In the following example, you access properties and methods of the new object using the object variable, <FONT FACE="Courier New" SIZE=2>ExcelSheet</FONT>, and other Excel objects, including the Application object and the Cells collection. For example:<P>

<BLOCKQUOTE>
<PRE><FONT FACE="Courier New" SIZE=3>' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True
' Place some text in the first cell of the sheet.
ExcelSheet.Cells(1,1).Value = "This is column A, row 1"
' Save the sheet.
ExcelSheet.SaveAs "C:\DOCS\TEST.XLS"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the object variable.
Set ExcelSheet = Nothing
</FONT></PRE></BLOCKQUOTE>
</BLOCKQUOTE>

<hr noshade size=1>
<p align=center><em><a href="../../common/colegal.htm">&copy; 1997 by Microsoft Corporation. All rights reserved.</a></em></p> 

</FONT>
</BODY>
</HTML>





























































































⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -