Dim swClassFact As SwDocumentMgr.SwDMClassFactory
Dim docMgrApp As SwDocumentMgr.SwDMApplication
Dim docDrw As SwDocumentMgr.SwDMDocument13
Dim res As SwDocumentMgr.SwDmDocumentOpenError
Set swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")
Set docMgrApp = swClassFact.GetApplication("your swdmkey")
Set docDrw = docMgrApp.GetDocument("C:\Program Files\SOLIDWORKS Corp\SolidWorks\samples\tutorial\advdrawings\foodprocessor.slddrw", SwDmDocumentType.swDmDocumentDrawing, True, res) '此为SW自带的工程图文件,初始状态获取结果是正确的。
Dim sheetNameVar As Variant
Dim sheetCount As Long
sheetCount = docDrw.GetSheetCount
sheetNameVar = docDrw.GetSheetNames
Dim i As Integer
For i = 0 To sheetCount - 1
Debug.Print sheetNameVar(i)
Next