I'm trying to have access to Autodesk Autocad Application trough Calc, passing to Autocad some coordinates in order to drawn a simple rectangle just for test.
The below procedure has been developed inside CALC macro area but I have some problem, receiving an error messagge.
Here attached the code, and msg error window.
Code: Select all
Sub Main
Dim AutocadApp As Object
Dim AutocadDoc As Object
Dim RectArray(0 To 9) As Double
Dim Rectangle As Object
Dim oFactory, oApp, oSess, oFolder
Dim oSheet As Object
'****** Launch Autocad application****
oSheets = ThisComponent.getSheets()
oSheet = oSheets.getByIndex(0)
oCell = oSheet.getCellByPosition(2, 5)
oCell1 = oSheet.getCellByPosition(2, 6)
Q=oCell.getValue()
R=oCell1.getValue()
''****Point 1****
RectArray(0) = 0
RectArray(1) = 0
''****Point 2****
RectArray(2) = Q
RectArray(3) = 0
''****Point 3****
RectArray(4) = Q
RectArray(5) = R
''****Point 4****
RectArray(6) = 0
RectArray(7) = R
''****Point 5****
RectArray(8) = 0
RectArray(9) = 0
oFactory = createUnoService("com.sun.star.bridge.oleautomation.Factory")
oApp = oFactory.createInstance("Autocad.Application")
oApp.Visible = True
''****Draw rectangle****
Set AutocadDoc = oApp.ActiveDocument
Set Rectangle = AutocadDoc.ModelSpace.AddLightWeightPolyline(RectArray)
End Sub
The procedure hangs on " Set Rectangle = AutocadDoc.ModelSpace.AddLightWeightPolyline(RectArray) " even if syntax it's correct.
Here below the error message.