View Single Post
 
Old 07-28-2011, 12:02 AM
Catalin.B Catalin.B is offline Windows Vista Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

You can start with this macro for the sample document.

Sub UpdateEmbeddedXLSX()
Dim workbook As InlineShape
For Each workbook In ActiveDocument.InlineShapes
With workbook
If .Type = wdInlineShapeEmbeddedOLEObject Then
''# Excel.Sheet.12 for Excel 2007
If .OLEFormat.ClassType = "Excel.Sheet.12" Then
''# Open Object as spreadsheet
.OLEFormat.DoVerb wdOLEVerbPrimary
''# If you want, you can also do any updates here like
.OLEFormat.Object.ActiveSheet.Cells(2, 2).Value = ".1"
''# Nasty - but it works - SendKeys
SendKeys "{ESC}", True
End If
End If
End With
Next
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub


If you want the macro to run at opening the document, you have to do this settings
To make an existing macro execute whenever you open a document in Microsoft Word, rename it "AutoOpen" by clicking "View," "Macro," "View Macros ...," then choosing the existing macro and clicking "Edit." In the resulting screen, edit the two top lines in the VBA code window to replace the current macro name with "AutoOpen."
Attached Files
File Type: docx New Document Microsoft Office Word.docx (16.9 KB, 7 views)
Reply With Quote