简体   繁体   English

VBA 能否打开嵌入在 Excel 工作簿中的文档

[英]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.如果我想用 VBA 从 Excel 打开 a.oft 文档,我通常会在 VBA 中指明 .oft 文档的文件夹路径。

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??是否可以在 Excel 文件中附加/嵌入 this.oft 并指示 VBA 从 Excel 文件打开它而不是指示文件夹路径?

Thanks!谢谢!

Here's a code sample for VB.NET from Word to give you an idea of the code constructs you need to use.这是 Word 中 VB.NET 的代码示例,让您了解需要使用的代码结构。 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). 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.只需搜索 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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