Article ID: 128711
Article Last Modified on 10/11/2006
Sub Embedded_Ole_Object_Using_xlPrimary()
'Activates the object
ActiveSheet.DrawingObjects("Picture 1").Verb (xlPrimary)
Set myobj = CreateObject("word.basic") 'Creates a Word Basic object
With myobj
.Insert "Hello" 'Word Basic commands
.Insertpara
.Insertpara
.Insert "Goodbye"
End With
Set myobj = Nothing 'clears the object
Range("a1").Select 'selects cell A1
End Sub
Sub Embedded_Ole_Object_Using_xlOpen()
'Opens up Word
ActiveSheet.DrawingObjects("Picture 1").Verb (xlOpen)
Set myobj = CreateObject("word.basic") 'creates a Word Basic object
With myobj
.Insert "Hello" 'Word Basic commands
.Insertpara
.Insertpara
.Insert "Goodbye"
End With
'Sends keystrokes to close Word
SendKeys "%fx{TAB}{ENTER}", True
Set myobj = Nothing 'clears the object
Range("a1").Select 'selects cell A1
End Sub
Sub Clearit()
'Activates the object
ActiveSheet.DrawingObjects("Picture 1").Verb
'Creates a Word Basic object
Set myobj = CreateObject("word.basic")
With myobj
.EditSelectAll 'Word Basic commands
.EditClear
End With
Set myobj = Nothing 'clears the object
Range("a1").Select 'selects cell A1
End Sub
To use these subroutines, do the following to set up the workbook:
verb
Additional query words: XL
Keywords: KB128711