Sub detectType()
Dim mediaDescr(3) as new com.sun.star.beans.PropertyValue
docurl = thisComponent.getURL()
mediaDescr(0).Name = "URL"
mediaDescr(0).Value = docurl
typemgr = createUnoService("com.sun.star.document.TypeDetection")
'make deep type detection (not just based on filename extension)
msgbox typemgr.queryTypeByDescriptor(mediaDescr(), True)
End Sub
Dim mediaDescr(3) as new com.sun.star.beans.PropertyValue
docurl = thisComponent.getURL()
mediaDescr(0).Name = "URL"
mediaDescr(0).Value = docurl
typemgr = createUnoService("com.sun.star.document.TypeDetection")
'make deep type detection (not just based on filename extension)
msgbox typemgr.queryTypeByDescriptor(mediaDescr(), True)
End Sub
本文介绍了一种使用StarOffice API来检测并确定文档类型的宏脚本实现方法。通过设置一系列属性值,如文档的URL,并利用TypeDetection服务进行深层次的文档类型检测,而不仅仅是依赖文件扩展名。
710

被折叠的 条评论
为什么被折叠?



