ObjectFrame.SourceDoc property (Access)

Use the SourceDoc property to specify the file to create a link to or to embed when you create a linked object or embedded object by using the Action property in Visual Basic. Read/write String.

Syntax

expression.SourceDoc

expression A variable that represents an ObjectFrame object.

Remarks

For an embedded object, enter the full path and file name for the file that you want to use as a template, and set the Action property to acOLECreateEmbed.

For a linked object, enter the full path and file name of the file to create a link to, and set the Action property to acOLECreateLink.

While this property appears in the property sheet, it takes effect only after the Action property is set in a macro or by using Visual Basic.

Use the SourceDoc property to specify the file to create a link to, and you can use the control's SourceItem property to specify the data within that file. If you want to create a link to the entire object, leave the SourceItem property blank.

When a linked unbound object is created, the control's SourceItem property setting is concatenated with its SourceItem property setting. In Form view, Datasheet view, and Print Preview, the control's SourceItem property setting is a zero-length string (" ").

Its SourceDoc property setting is the full path to the linked file, followed by an exclamation point (!) or a backslash (\) and the SourceItem property setting, as in the following example.

"C:\Work\Qtr1\Revenue.xls!R1C1:R30C15"

Example

The following example creates a linked OLE object by using an unbound object frame named OLE1, and sizes the control to display the object's entire contents when the user chooses a command button.

Sub Command1_Click 
 OLE1.Class = "Excel.Sheet" ' Set class name. 
 ' Specify type of object. 
 OLE1.OLETypeAllowed = acOLELinked 
 ' Specify source file. 
 OLE1.SourceDoc = "C:\Excel\Oletext.xls" 
 ' Specify data to create link to. 
 OLE1.SourceItem = "R1C1:R5C5" 
 ' Create linked object. 
 OLE1.Action = acOLECreateLink 
 ' Adjust control size. 
 OLE1.SizeMode = acOLESizeZoom 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.