How to modify embedded MS Office document
Say you have a Bound Object Frame on your form, bound to OLE Object field type. User has inserted a MS Office document there, for example Excel Sheet, and you want to modify it contents. The trick is that you have to activate field first, using Action property, and then modify its content. Here a code from sample procedure:
Private Sub cmdModifyExcel_Click()
Dim oSheet As Object
Me.oleExcelObj.Action = acOLEActivate
Set oSheet = Me.oleExcelObj.Object.Sheets(1)
oSheet.Cells(1, 1).Value = "Hi from VBA!"
Me.oleExcelObj.Action = acOLEClose
Set oSheet = Nothing
End Sub
1 Comments:
Thanks for sharing and keep sharing these kind of informative posts.
Post a Comment
<< Home