You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检查ActivePresentation文件类型并以MsgBox显示结果?

Checking ActivePresentation File Type in VBA & Displaying Results with MsgBox

Perfect, since you already have the workflow down for Word and Excel, let's translate that to PowerPoint quickly:

First, a recap of what you already know:

  • Word: MsgBox ActiveDocument.SaveFormat
  • Excel: MsgBox ActiveWorkbook.FileFormat

For PowerPoint, the property we use aligns with Word's approach rather than Excel's. You'll use the SaveFormat property of the ActivePresentation object. Here's the basic one-liner to display the numeric format code:

MsgBox ActivePresentation.SaveFormat

A Quick Note on the Value

That numeric value corresponds to specific PowerPoint file formats. For example:

  • 1 = PowerPoint 97-2003 (.ppt)
  • 24 = Standard PowerPoint (.pptx)
  • 25 = Macro-enabled PowerPoint (.pptm)
  • 32 = PowerPoint Template (.potx)

If you want a more user-friendly output instead of just a number, you can wrap it in a simple Select Case block to translate the code to a readable description:

Dim formatDescription As String

Select Case ActivePresentation.SaveFormat
    Case 1: formatDescription = "PowerPoint 97-2003 Presentation (.ppt)"
    Case 24: formatDescription = "PowerPoint Presentation (.pptx)"
    Case 25: formatDescription = "PowerPoint Macro-Enabled Presentation (.pptm)"
    Case 32: formatDescription = "PowerPoint Template (.potx)"
    Case 35: formatDescription = "PowerPoint Show (.ppsx)"
    ' Add additional cases for other formats you need to handle
    Case Else: formatDescription = "Unknown Format (Code: " & ActivePresentation.SaveFormat & ")"
End Select

MsgBox "Current Presentation File Format: " & formatDescription

That should give you exactly what you need—whether you want the raw format code or a clear, human-readable label.

内容的提问来源于stack exchange,提问作者Ivgeni Feldman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:04:06