I have a Word document with two embedded Excel files (added using Insert -> Object -> Create From File) which I wish to modify using Word VBA. I have got to the point where
I have a solution to my own problem. Any further comments will be appreciated -
Sub TestMacro()
Dim lNumShapes As Long
Dim lShapeCnt As Long
Dim xlApp As Object
Dim wrdActDoc As Document
Set wrdActDoc = ActiveDocument
For lShapeCnt = 1 To 1 'wrdActDoc.InlineShapes.Count
If wrdActDoc.InlineShapes(lShapeCnt).Type = wdInlineShapeEmbeddedOLEObject Then
If wrdActDoc.InlineShapes(lShapeCnt).OLEFormat.ProgID = "Excel.Sheet.8" Then
wrdActDoc.InlineShapes(lShapeCnt).OLEFormat.Edit
Set xlApp = GetObject(, "Excel.Application")
xlApp.Workbooks(1).Worksheets(1).Range("A1") = "This is A modified"
xlApp.Workbooks(1).Save
xlApp.Workbooks(1).Close
xlApp.Quit
End If
End If
Next lShapeCnt
End Sub