Article ID: 158929
Article Last Modified on 1/19/2007
A1 : Name B1 : Salary C1 : Dept. D1 : Qty Sold
A2 : Nancy Davolio B2 : 16,000 C2 : 9 D2 : 19
A3 : Andrew Fuller B3 : 25,000 C3 : 3 D3 : 129
A4 : Michael Suyama B4 : 28,500 C4 : 3 D4 : 234
A5 : Janice Leverling B5 : 30,000 C5 : 12 D5 : 199
A6 : Linda Callahan B6 : 50,000 C6 : 9 D6 : 126
A7 : Johnathan King B7 : 50,000 C7 : 12 D7 : 45
Private Sub cmdOLEAuto_Click()
On Error GoTo Error_cmdOleAuto_Click
With Me![OLEExcelSheet]
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLELinked
' Class statement--optional for Excel worksheet.
.Class = "Excel.Sheet"
' Specify the file to be linked.
' Type the correct path name.
.SourceDoc = "c:\<pathname>\TestOLEAuto.xls"
' Range statement--optional for Excel worksheet.
.SourceItem = "R1C1:R7C4"
' Create the linked object.
.Action = acOLECreateLink
' Optional size adjustment.
.SizeMode = acOLESizeZoom
End With
Exit_cmdOLEAuto_Click:
Exit Sub
Error_cmdOleAuto_Click:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_cmdOLEAuto_Click
End Sub
Unbound Object Frame
--------------------
Name: OLEWordDoc
Height: 11"
Private Sub cmdOLEAuto_Click()
On Error GoTo Error_cmdOLEAuto_Click
With Me![OLEWordDoc]
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLEEmbedded
' Class statement for Word document.
.Class = "Word.Document"
' Specify the file to be embedded.
' Type the correct path name.
.SourceDoc = "c:\<pathname>\TestOLEAuto.doc"
' Create the embedded object.
.Action = acOLECreateEmbed
' Optional size adjustment.
.SizeMode = acOLESizeZoom
End With
Exit_cmdOLEAuto_Click:
Exit Sub
Error_cmdOLEAuto_Click:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_cmdOLEAuto_Click
End Sub
123859 ACC: Sample OLE Automation for MS Word and MS Excel
132003 ACC: How to Save a Copy of an Embedded MS Word Document
114214 ACC2: How to Programmatically Embed or Link an Object in a Form
Keywords: kbhowto kbprogramming KB158929