SourceDoc Property

See Also309T0V5              Example3N3AMKG>Low

Applies To

OLE control2HQDVVU.

Description

Determines the file name to use when you create an OLE object.

Usage

[form.]ole.SourceDoc [ = filename ]

Remarks

Use the SourceDoc property to specify the file to be linked when creating a linked object (set Action = 1).  Use the SourceItem property to specify data within the file to be linked.

When creating an embedded object (set Action = 0), if the SourceDoc property is set to a valid file name, an embedded object is created using the specified file as a template.

When a linked object is created, the SourceItem property is concatenated to the SourceDoc property.  At run time, the SourceItem property returns an empty string ("") and the SourceDoc property returns the entire path to the linked file, followed by an exclamation point (!) or a backslash (\), followed by the SourceItem.  For example:

"C:\WORK\QTR1\REVENUE.XLS!R1C1:R30C15"

Data Type

String7WSH0XQ


See Also

Help:

Action Property04T78S3

Class PropertyVN4BZO

OleType Property12K24M2

OleTypeAllowed Property633XBW1

SourceItem PropertyZ9ATER

 

Programmer's Guide:

Chapter 22, "Object Linking and Embedding (OLE)"


SourceDoc, SourceItem Properties Example

The example creates a linked OLE object when the user clicks the command button.  First, use Microsoft Excel to create a spreadsheet named OLETEST.XLS.  Then create a form with an OLE control named Ole1.  When the Insert Object dialog is displayed, choose Cancel.  Place a command button on the form and copy the following code into the form's Declarations section, and then press F5.  The file OLETEST.XLS must exist in the specified path.

Sub Command1_Click
   ' Set class.
   Ole1.Class = "ExcelWorksheet"
   ' Specify source file.
   Ole1.SourceDoc = "C:\EXCEL\OLETEST.XLS"
   ' Specify the data within the file to be linked.
   Ole1.SourceItem = "R1C1:R5C5"
   ' Create a linked object using OleTest.xls.
   Ole1.Action = 1
End Sub