简体   繁体   中英

Can VBA open a document embedded in an Excel workbook

If I want to open a.oft document from Excel with VBA, I normally indicate the folder path to the.oft document in VBA.

Is it possible to attach/emmbed this.oft in the Excel file and indicate VBA to open it from the Excel file instead of indicating a folder path??

Thanks!

Here's a code sample for VB.NET from Word to give you an idea of the code constructs you need to use. Note that the Excel VBA model and Word VBA model differ and sometimes use different function/method names (I don't know for sure but this sometimes happens). Just search the guides at Microsoft.

For Each shp As InlineShape In wordDoc.Content.InlineShapes
  If shp.Type = WdInlineShapeType.wdInlineShapeEmbeddedOLEObject Then
     If shp.OLEFormat.ProgID.Contains("Word") Then
        shp.open()  ' Open the embedded Word document
     end if
  end if
next

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM