Jump to content

Utility.GetEntity в Excel vba не работает: Invalid procedure call or argument


Recommended Posts

Мне надо выполнить кое-какую обработку многострочного текста.

Пишу самую простую процедуру выбора этого самого текста:

Option Explicit
Public app As Nanocad.Application 'NanoCAD application global var
Public ThisDrawing As Nanocad.Document 'Active NanoCAD document global var
Sub my_drawing()
Dim MTxt As AcadMText
Dim ChoosedObject As AcadObject
Dim Point As Variant
Dim i As Integer

Set app = GetObject("", "nanoCAD.Application") 'Connect to running nanoCAD
app.Visible = True 'Show NanoCAD window
Set ThisDrawing = app.ActiveDocument 'Connect to nanoCAD doc

ThisDrawing.Utility.GetEntity ChoosedObject, Point, "Choose MText"
If ChoosedObject.EntityName <> "MText" Then
	i = MsgBox("Not an MText, vbCritical, "Wrong choose")
Else
	MTxt = ChoosedObject
	' Other code
End If

End Sub

 

Не могу добиться работоспособности строчки ThisDrawing.Utility.GetEntity ChoosedObject, Point, "Choose MText".

Окно Nanocad отображается на экране, появляется запрос на выбор объекта, я выбираю этот объект - а потом VBA мне сообщает: Invalid procedure call or argument.

Продолжение работы через On Error Resume Next не помогает: в переменной ChoosedObject не записывается ничего.

 

Макрос пишу в редакторе VBA Microsoft Excel 2007. Nanocad 8.5

Что тут можно сделать?

Link to comment
Share on other sites

пробуй позднее связывание, или хотя бы так

Dim ChoosedObject As Object

всеравно инвалид?

Link to comment
Share on other sites

не благодари

Option Explicit
Public app As nanoCAD.Application 'NanoCAD application global var
Public ThisDrawing As nanoCAD.Document 'Active NanoCAD document global var
Sub my_drawing()
  '  Dim MTxt As Object
    Dim ChoosedObject As Variant
    Dim Point As Variant
 '   Dim i As Integer

    Set app = GetObject("", "nanoCAD.Application") 'Connect to running nanoCAD
    app.Visible = True 'Show NanoCAD window
    Set ThisDrawing = app.ActiveDocument 'Connect to nanoCAD doc

    ThisDrawing.Utility.GetEntity ChoosedObject, Point, "Choose MText"
    If ChoosedObject.EntityName <> "AcDbMText" Then
		    MsgBox "Not an MText, vbCritical"
    Else
		    MsgBox ChoosedObject.TextString
		    ' Other code
    End If

End Sub

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Tell a friend

    Love Официальный форум компании Нанософт? Tell a friend!
×
×
  • Create New...