У меня возникли проблемы с обработкой массива Variant строк, возвращаемого вызовом метода в AutoCAD. Возвращаемый массив выглядит кошерно, но когда я пытаюсь ссылаться на элементы в массиве, или даже включать имя массива в для каждого оператора, я получаю ошибку типа несовпаденияVBScript Array Of Strings - Ошибка 800A000D Несоответствие типа
Вот код:
Dim acApp 'As AutoCAD.AcadApplication
Dim acDoc 'As AutoCAD.AcadDocument
Dim acLyt 'As AutoCAD.AcadLayout
'Get the AutoCAD application...
On Error Resume Next
Set acApp = GetObject(, "AutoCAD.Application")
On Error GoTo 0
If (acApp Is Nothing) Then
Set acApp = CreateObject("AutoCAD.Application")
End If
'Is there a drawing open? If not we'll need to open a new drawing...
If acApp.Documents.Count > 0 Then
Set acDoc = acApp.ActiveDocument
Else
Set acDoc = acApp.Documents.Add
End If
'Get a reference to the Model Space layout (always first)...
Set acLyt = acDoc.Layouts(0)
'Get the list of canonical media names ("A4", "A3" etc) for the plot device for this layout...
'The AutoCAD documentation says that this method returns a variant, which is an array of strings,
'which seems to be what is actually returned.'
'However, I can't reference the array elements without producing a "Type Mismatch" error.
Names = acLyt.GetCanonicalMediaNames()
WScript.Echo VarType(Names) 'This line runs ok, and returns 8200, which is 8192 for Variant Array, + 8 for String.
WScript.Echo Names(0) 'This line generates the error...
Я озадачен, поэтому любая помощь будет оценена по достоинству.
Paul
спасибо за ваш ответ. Я пробовал эти тесты, и первый преуспел там, где последний этого не сделал. Это всего лишь одномерный массив. – pdr0663