我有这个宏可以将文档中的所有形状转换为图像:
Dim i As Integer, oShp As Shape
For i = ActiveDocument.Shapes.Count To 1 Step -1
Set oShp = ActiveDocument.Shapes(i)
oShp.Select
Selection.Cut
Selection.PasteSpecial Link:=False, dataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next i
But I want to convert all math formulas to image. How can I change this macro to do this?
UPDATE:
我尝试了这段代码,但不起作用:(没有错误,也没有结果)
Sub AllEquationToPic()
Dim z As Integer, equation As OMath
For z = ActiveDocument.InlineShapes.Count To 1 Step -1
Set equation = ActiveDocument.OMaths(z)
equation.Range.Select
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next z
End Sub
您正在迭代InlineShapes
收集但使用z
访问OMaths
收藏。那是无稽之谈。
那么试试这个:
Sub AllEquationToPic()
Dim z As Integer, equation As OMath
For z = ActiveDocument.OMaths.Count To 1 Step -1
Set equation = ActiveDocument.OMaths(z)
equation.Range.Select
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
Next z
End Sub
Edit:这是一种更适合内联公式的替代方案,尽管结果图像质量稍差:
Sub FormulaDoc2PicDoc()
Dim doc As Document, docPath As String, htmPath As String
Dim alertStatus
alertStatus = Application.DisplayAlerts
Application.DisplayAlerts = wdAlertsNone
Set doc = ActiveDocument
docPath = doc.FullName
htmPath = docPath & ".htm"
doc.SaveAs htmPath, wdFormatFilteredHTML
doc.Close False
Application.DisplayAlerts = alertStatus
Set doc = Documents.Open(htmPath, False)
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)