<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Invalid input in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9054517#M10200</link>
    <description>&lt;PRE&gt;Sub ScanBlks123()
    Dim dybprop As Variant, i As Integer
    Dim bobj As AcadEntity
     Dim ThisDrawing As AcadDocument
         Set ThisDrawing = AcadApplication.ActiveDocument
  For Each bobj In ThisDrawing.ModelSpace 'Get AutoCAD Entity's
    Debug.Print bobj.ObjectName
        If bobj.ObjectName = "AcDbBlockReference" Then 'Check if BlockRef
            If bobj.IsDynamicBlock Then 'Check to see if it is a Dynamic Block
            dybprop = bobj.GetDynamicBlockProperties
                 If bobj.EffectiveName Like "FSM4L*" Then 'Finds Dynamic Block NAME
                 dybprop = bobj.GetDynamicBlockProperties
                For i = LBound(dybprop) To UBound(dybprop) 'Goes through Results
                    If dybprop(i).PropertyName = "Distance8" Then 'Looks for the PropertyName
                    dybprop(i).Value = "20" 'Change the Value of the PropertyName
                    End If
                Next i
                End If
            End If
        End If
        Next
End Sub

Public Sub ScanBlks() 'visib code
    Dim dybprop As Variant, i As Integer
    Dim bobj As AcadEntity
    Dim ThisDrawing As AcadDocument
    Dim abc As String
   With Workbooks("Make-A-Run Trial 02(phase two_01)")
 'abc = ThisWorkbook.Worksheets("Macro1").Range("s3").Value
    Set ThisDrawing = AcadApplication.ActiveDocument
    With Sheets("Configurations")
    abc = Range("O5")
    For Each bobj In ThisDrawing.ModelSpace
        If bobj.ObjectName = "AcDbBlockReference" Then
            If bobj.IsDynamicBlock Then
                If bobj.EffectiveName Like "FSM4L*" Then
                    dybprop = bobj.GetDynamicBlockProperties
                    For i = LBound(dybprop) To UBound(dybprop)
                        If dybprop(i).PropertyName = "Visibility1" Then
                            dybprop(i).Value = "TF"
                            ThisDrawing.Regen acActiveViewport
                        End If
                    Next i
                End If
            End If
        End If
    Next
    SendAutoCADCommands
    End With
End With
End Sub&lt;/PRE&gt;&lt;P&gt;Hello everyone, good morning, I am having a very similar issue to the one already answered but I'm having trouble resolving it by referencing this answer, hopefully someone can help me? I am trying to stretch a dynamic block but am having difficulty doing so. I have a fully functioning code to change visibility on a dynamic block, so I thought it'd be quite similar and easy to figure out but apparently not. I'll post both codes and a dwg. of my block if it helps. Thank you!&lt;/P&gt;</description>
    <pubDate>Sat, 28 Sep 2019 13:21:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-09-28T13:21:36Z</dc:date>
    <item>
      <title>Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5350841#M10191</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added a photo of the problem i get. When i run my vba&amp;nbsp;program i get a error on this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;oDblkProp.Value = txtHoogte&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know what the problem is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the error is : Run-Time error ' -2145386493 ( 80200003)'&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invalid Input&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How dan i fix this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is a copy of my vba-code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim objBlok1 As AcadBlockReference&lt;BR /&gt;Dim strPath As String&lt;BR /&gt;Dim oprops As Variant&lt;BR /&gt;Dim oDblkProp As AcadDynamicBlockReferenceProperty&lt;BR /&gt;Dim i As Integer&lt;/P&gt;&lt;P&gt;dblInvoegpunt(0) = 0: dblInvoegpunt(1) = 0: dblInvoegpunt(2) = 0&lt;BR /&gt;Set objBlok1 = ThisDrawing.ModelSpace.InsertBlock(dblInvoegpunt, "C:\Autocad\Definitieve blocks\1.Onderkast\1.Vooraanzichten\Niet Beplakt\Vooraanzicht.NB.Doorlopende Stijlen.dwg", 1#, 1#, 1#, 0#)&lt;/P&gt;&lt;P&gt;If objBlok1.IsDynamicBlock Then&lt;BR /&gt;oprops = objBlok1.GetDynamicBlockProperties&lt;BR /&gt;For i = 0 To UBound(oprops)&lt;BR /&gt;Set oDblkProp = oprops(i)&lt;BR /&gt;If oDblkProp.PropertyName = "Hoogte" Then&lt;BR /&gt;'oDblkProp.Value = "txtHoogte" 'Hoogte van de kast&lt;BR /&gt;oDblkProp.Value = txtHoogte&lt;BR /&gt;Exit For&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thankyou&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Oct 2014 13:57:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5350841#M10191</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-21T13:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352805#M10192</link>
      <description>&lt;P&gt;as you can read from AutoCAD ActiveX and VBA Reference, "PropertyName" property of "AcadDynamicBlockReferenceProperty" object is read-only: you can't set it, you can only read it&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 05:49:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352805#M10192</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T05:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352807#M10193</link>
      <description>&lt;P&gt;How can i change that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 05:53:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352807#M10193</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T05:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352811#M10194</link>
      <description>How to change the read only? i don't see the answer..</description>
      <pubDate>Wed, 22 Oct 2014 05:57:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352811#M10194</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T05:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352815#M10195</link>
      <description>&lt;P&gt;you can't through VBA simply&lt;/P&gt;&lt;P&gt;the online reference for "PropertyName" property of "AcadDynamicBlockReferenceProperty" object says "Property names are guaranteed to be unique among all properties on a given block reference"&lt;/P&gt;&lt;P&gt;which is the reason it's a read-only property: VBA won't let you set a name that could violate this uniqueness requirement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;don't know whether lisp could help you, but I'd guess would not&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 06:03:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352815#M10195</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T06:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352847#M10196</link>
      <description>&lt;P&gt;And what i i make the name unique of every block? Like Height1, Height2,Height3, ... Would it work then?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if the propertyname is unique could it work then ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a college of mine says its because there are more propertynames with the name height and because of that i get the error&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 06:36:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5352847#M10196</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T06:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353231#M10197</link>
      <description>&lt;P&gt;as long as&amp;nbsp;you deal with a&amp;nbsp;read-only property&amp;nbsp;you can't assign it any value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 11:26:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353231#M10197</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T11:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353239#M10198</link>
      <description>&lt;P&gt;I found a solution &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;txtHoogte = frmKast.txtHoogte.Value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i added this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim HoogteKast As Double&lt;BR /&gt;HoogteKast = txtHoogte&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and replaced this code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;oDblkProp.Value = HoogteKast&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No errors anymore,&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry but i have a other question.&lt;/P&gt;&lt;P&gt;I put my codes in a module. But how can i run the min my form?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tryed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If chkCoAlgemeen = True Then &amp;nbsp;' when it need to be loaded&lt;BR /&gt;Call Mod_VAZAlgemeen '( modulename)&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when i run my program nothing happens&lt;/P&gt;&lt;P&gt;in autocad i see:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command: Regenerating model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its the only thing that happens.&lt;/P&gt;&lt;P&gt;Do you know what i have to do?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 11:32:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353239#M10198</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T11:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353465#M10199</link>
      <description>&lt;P&gt;I must apologize since&amp;nbsp;I only now realize I was telling you about "PropertyName" property&amp;nbsp;of "AcadDynamicBlockReferenceProperty" object&amp;nbsp;while you asked for its "Value" property.&lt;/P&gt;&lt;P&gt;And while the&amp;nbsp;former is read-only, this latter is read-write.&amp;nbsp;Glad to see you already solved your problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as for your last question, see the specific topic you already opened.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2014 13:33:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/5353465#M10199</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-22T13:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9054517#M10200</link>
      <description>&lt;PRE&gt;Sub ScanBlks123()
    Dim dybprop As Variant, i As Integer
    Dim bobj As AcadEntity
     Dim ThisDrawing As AcadDocument
         Set ThisDrawing = AcadApplication.ActiveDocument
  For Each bobj In ThisDrawing.ModelSpace 'Get AutoCAD Entity's
    Debug.Print bobj.ObjectName
        If bobj.ObjectName = "AcDbBlockReference" Then 'Check if BlockRef
            If bobj.IsDynamicBlock Then 'Check to see if it is a Dynamic Block
            dybprop = bobj.GetDynamicBlockProperties
                 If bobj.EffectiveName Like "FSM4L*" Then 'Finds Dynamic Block NAME
                 dybprop = bobj.GetDynamicBlockProperties
                For i = LBound(dybprop) To UBound(dybprop) 'Goes through Results
                    If dybprop(i).PropertyName = "Distance8" Then 'Looks for the PropertyName
                    dybprop(i).Value = "20" 'Change the Value of the PropertyName
                    End If
                Next i
                End If
            End If
        End If
        Next
End Sub

Public Sub ScanBlks() 'visib code
    Dim dybprop As Variant, i As Integer
    Dim bobj As AcadEntity
    Dim ThisDrawing As AcadDocument
    Dim abc As String
   With Workbooks("Make-A-Run Trial 02(phase two_01)")
 'abc = ThisWorkbook.Worksheets("Macro1").Range("s3").Value
    Set ThisDrawing = AcadApplication.ActiveDocument
    With Sheets("Configurations")
    abc = Range("O5")
    For Each bobj In ThisDrawing.ModelSpace
        If bobj.ObjectName = "AcDbBlockReference" Then
            If bobj.IsDynamicBlock Then
                If bobj.EffectiveName Like "FSM4L*" Then
                    dybprop = bobj.GetDynamicBlockProperties
                    For i = LBound(dybprop) To UBound(dybprop)
                        If dybprop(i).PropertyName = "Visibility1" Then
                            dybprop(i).Value = "TF"
                            ThisDrawing.Regen acActiveViewport
                        End If
                    Next i
                End If
            End If
        End If
    Next
    SendAutoCADCommands
    End With
End With
End Sub&lt;/PRE&gt;&lt;P&gt;Hello everyone, good morning, I am having a very similar issue to the one already answered but I'm having trouble resolving it by referencing this answer, hopefully someone can help me? I am trying to stretch a dynamic block but am having difficulty doing so. I have a fully functioning code to change visibility on a dynamic block, so I thought it'd be quite similar and easy to figure out but apparently not. I'll post both codes and a dwg. of my block if it helps. Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 13:21:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9054517#M10200</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-28T13:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9055385#M10201</link>
      <description>&lt;P&gt;the "Stretch" act usually is associated with a "point" or "linear", so the dynamic property's value should be corresponding to the parameter. for "point", the Stretch action results in 2 properties: "[property name]&amp;nbsp; X" and "[property name] Y", each expect a real number (Double, in VBA); while for "linear" parameter, the corresponding property expect a real number (Double) as input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, it is very simple to fix your code -&amp;nbsp; change "20" (string) to 20.0 (number), as long as the value is in allowed scope (the linear parameter may have min and/or max value specified, as you surely know):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                ... ...&lt;BR /&gt;                For i = LBound(dybprop) To UBound(dybprop) 'Goes through Results
                    If dybprop(i).PropertyName = "Distance8" Then 'Looks for the PropertyName
                    &lt;FONT color="#FF0000"&gt;//&lt;/FONT&gt; dybprop(i).Value = "20" 'Change the Value of the PropertyName&lt;BR /&gt;                    &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dybprop(i).Value = 20.0&lt;/STRONG&gt;&lt;/FONT&gt;
                    End If
                Next i&lt;BR /&gt;                ... ...&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2019 12:57:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9055385#M10201</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-09-29T12:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9075805#M10202</link>
      <description>&lt;P&gt;Good morning Norman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct, I also found out that you can put a hashtag ahead of the number and this will work as well. The thing that I am struggling with now is setting a consecutive loop of inserting the blocks, adjusting the length by the "stretch" and adjusting the visibility. I have the code for inserting blocks in a loop, where the coordinates, scale factors and rotation angle can all be defined, but trying to throw the stretch and visibility options in there is giving me a hard time. I have the code to modify the stretch and visbility properties individually now (thanks to your last comment) but I can't seem to mix it all together. Maybe I can post it on here and you can take a look at it? It'd be greatly appreciated. Also if anyone else is working on a similar project, feel free to open up the content, it's meant to be super user-friendly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 11:45:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9075805#M10202</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-09T11:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid input</title>
      <link>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9075815#M10203</link>
      <description>&lt;P&gt;*UNABLE TO UPLOAD EXCEL WORKBOOK*&lt;/P&gt;&lt;P&gt;'Reference FOR WORKING CODE&lt;/P&gt;&lt;P&gt;'THIS CODE WILL INSERT STATIC BLOCKS WHILE MANIPULATING THE PLOTTING COORDINATES, X-Y-Z, SCALE, X-Y-Z-, AND ROTATION ANGLE&lt;BR /&gt;Sub Start_Up01()&lt;BR /&gt;&lt;BR /&gt;'Declaring the necessary variables.&lt;BR /&gt;Dim acadApp As Object&lt;BR /&gt;Dim acadDoc As Object&lt;BR /&gt;Dim acadBlock As Object&lt;BR /&gt;Dim LastRow As Long&lt;BR /&gt;Dim I As Long&lt;BR /&gt;Dim InsertionPoint(0 To 2) As Double&lt;BR /&gt;Dim BlockName As String&lt;BR /&gt;Dim BlockScale As ScaleFactor&lt;BR /&gt;Dim RotationAngle As Double&lt;BR /&gt;&lt;BR /&gt;'Activate the coordinates sheet and find the last row.&lt;BR /&gt;With Sheets("Coordinates")&lt;BR /&gt;.Activate&lt;BR /&gt;LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;'Check if there are coordinates for at least one circle.&lt;BR /&gt;If LastRow &amp;lt; 2 Then&lt;BR /&gt;MsgBox "There are no coordinates for the insertion point!", vbCritical, "Insertion Point Error"&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'Check if AutoCAD application is open. If is not opened create a new instance and make it visible.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set acadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;If acadApp Is Nothing Then&lt;BR /&gt;Set acadApp = CreateObject("AutoCAD.Application")&lt;BR /&gt;acadApp.Visible = True&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'Check (again) if there is an AutoCAD object.&lt;BR /&gt;If acadApp Is Nothing Then&lt;BR /&gt;MsgBox "Sorry, it was impossible to start AutoCAD!", vbCritical, "AutoCAD Error"&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;'If there is no active drawing create a new one.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set acadDoc = acadApp.ActiveDocument&lt;BR /&gt;If acadDoc Is Nothing Then&lt;BR /&gt;Set acadDoc = acadApp.Documents.Add&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;/P&gt;&lt;P&gt;'Check if the active space is paper space and change it to model space.&lt;BR /&gt;If acadDoc.ActiveSpace = 0 Then '0 = acPaperSpace in early binding&lt;BR /&gt;acadDoc.ActiveSpace = 1 '1 = acModelSpace in early binding&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;'Loop through all the rows and add the corresponding blocks in AutoCAD.&lt;BR /&gt;With Sheets("Coordinates")&lt;BR /&gt;For I = 2 To LastRow&lt;BR /&gt;'Set the block name.&lt;BR /&gt;BlockName = .Range("D" &amp;amp; I).Value&lt;BR /&gt;'If the block name is not empty, insert the block.&lt;BR /&gt;If BlockName &amp;lt;&amp;gt; vbNullString Then&lt;BR /&gt;'Set the insertion point.&lt;BR /&gt;InsertionPoint(0) = .Range("A" &amp;amp; I).Value&lt;BR /&gt;InsertionPoint(1) = .Range("B" &amp;amp; I).Value&lt;BR /&gt;InsertionPoint(2) = .Range("C" &amp;amp; I).Value&lt;BR /&gt;'Initialize the optional parameters.&lt;BR /&gt;BlockScale.X = 1&lt;BR /&gt;BlockScale.Y = 1&lt;BR /&gt;BlockScale.Z = 1&lt;BR /&gt;RotationAngle = 0&lt;BR /&gt;'Set the optional parameters (if there are values on the corresponding ranges).&lt;BR /&gt;If .Range("E" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.X = .Range("E" &amp;amp; I).Value&lt;BR /&gt;If .Range("F" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.Y = .Range("F" &amp;amp; I).Value&lt;BR /&gt;If .Range("G" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.Z = .Range("G" &amp;amp; I).Value&lt;BR /&gt;If .Range("H" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then RotationAngle = .Range("H" &amp;amp; I).Value&lt;BR /&gt;'Add the block using the sheet data (insertion point, block name, scale factors and rotation angle).&lt;BR /&gt;'The 0.0174532925 is to convert degrees into radians.&lt;BR /&gt;Set acadBlock = acadDoc.ModelSpace.InsertBlock(InsertionPoint, BlockName, _&lt;BR /&gt;BlockScale.X, BlockScale.Y, BlockScale.Z, RotationAngle * 0.0174532925)&lt;BR /&gt;End If&lt;BR /&gt;Next I&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;acadApp.ZoomExtents&lt;/P&gt;&lt;P&gt;'Release the objects.&lt;BR /&gt;Set acadBlock = Nothing&lt;BR /&gt;Set acadDoc = Nothing&lt;BR /&gt;Set acadApp = Nothing&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MsgBox "Your Pattern is Now in AutoCAD!", vbInformation, "Finished"&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Current Code with Issue&lt;/P&gt;&lt;P&gt;Option Explicit&lt;/P&gt;&lt;P&gt;'A custom type that holds the scale factors of the block.&lt;BR /&gt;Private Type ScaleFactor&lt;BR /&gt;X As Double&lt;BR /&gt;Y As Double&lt;BR /&gt;Z As Double&lt;BR /&gt;End Type&lt;/P&gt;&lt;P&gt;Sub DynBlocksTest()&lt;/P&gt;&lt;P&gt;'--------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'--------------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;'Declaring the necessary variables.&lt;BR /&gt;Dim acadApp As Object&lt;BR /&gt;Dim acadDoc As Object&lt;BR /&gt;Dim acadBlock As Object&lt;BR /&gt;Dim LastRow As Long&lt;BR /&gt;Dim I As Long&lt;BR /&gt;Dim InsertionPoint(0 To 2) As Double&lt;BR /&gt;Dim BlockName As String&lt;BR /&gt;Dim BlockScale As ScaleFactor&lt;BR /&gt;Dim RotationAngle As Double&lt;BR /&gt;Dim dybprop As Object, O As Long&lt;BR /&gt;Set dybprop = acadBlock.GetDynamicBlockProperties&lt;BR /&gt;For O = LBound(dybprop) To UBound(dybprop)&lt;BR /&gt;'Activate the coordinates sheet and find the last row.&lt;BR /&gt;With Sheets("Coordinates")&lt;BR /&gt;.Activate&lt;BR /&gt;LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;'Check if there are coordinates for at least one circle.&lt;BR /&gt;If LastRow &amp;lt; 2 Then&lt;BR /&gt;MsgBox "There are no coordinates for the insertion point!", vbCritical, "Insertion Point Error"&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'Check if AutoCAD application is open. If is not opened create a new instance and make it visible.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set acadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;If acadApp Is Nothing Then&lt;BR /&gt;Set acadApp = CreateObject("AutoCAD.Application")&lt;BR /&gt;acadApp.Visible = True&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'Check (again) if there is an AutoCAD object.&lt;BR /&gt;If acadApp Is Nothing Then&lt;BR /&gt;MsgBox "Sorry, it was impossible to start AutoCAD!", vbCritical, "AutoCAD Error"&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;BR /&gt;&lt;BR /&gt;'If there is no active drawing create a new one.&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set acadDoc = acadApp.ActiveDocument&lt;BR /&gt;If acadDoc Is Nothing Then&lt;BR /&gt;Set acadDoc = acadApp.Documents.Add&lt;BR /&gt;End If&lt;BR /&gt;On Error GoTo 0&lt;/P&gt;&lt;P&gt;'Check if the active space is paper space and change it to model space.&lt;BR /&gt;If acadDoc.ActiveSpace = 0 Then '0 = acPaperSpace in early binding&lt;BR /&gt;acadDoc.ActiveSpace = 1 '1 = acModelSpace in early binding&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;'Loop through all the rows and add the corresponding blocks in AutoCAD.&lt;BR /&gt;With Sheets("Coordinates")&lt;BR /&gt;For I = 2 To LastRow&lt;BR /&gt;'Set the block name.&lt;BR /&gt;BlockName = .Range("D" &amp;amp; I).Value&lt;BR /&gt;If acadBlock.IsDynamicBlock Then&lt;BR /&gt;'If the block name is not empty, insert the block.&lt;BR /&gt;If BlockName &amp;lt;&amp;gt; vbNullString Then&lt;BR /&gt;'Set the insertion point.&lt;BR /&gt;InsertionPoint(0) = .Range("A" &amp;amp; I).Value&lt;BR /&gt;InsertionPoint(1) = .Range("B" &amp;amp; I).Value&lt;BR /&gt;InsertionPoint(2) = .Range("C" &amp;amp; I).Value&lt;BR /&gt;'Initialize the optional parameters.&lt;BR /&gt;BlockScale.X = 1&lt;BR /&gt;BlockScale.Y = 1&lt;BR /&gt;BlockScale.Z = 1&lt;BR /&gt;RotationAngle = 0&lt;BR /&gt;'Set the optional parameters (if there are values on the corresponding ranges).&lt;BR /&gt;If .Range("E" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.X = .Range("E" &amp;amp; I).Value&lt;BR /&gt;If .Range("F" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.Y = .Range("F" &amp;amp; I).Value&lt;BR /&gt;If .Range("G" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then BlockScale.Z = .Range("G" &amp;amp; I).Value&lt;BR /&gt;If .Range("H" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then RotationAngle = .Range("H" &amp;amp; I).Value&lt;BR /&gt;If .Range("I" &amp;amp; I).Value &amp;lt;&amp;gt; vbNullString Then dybprop(O).Value = .Range("I" &amp;amp; I).Value&lt;BR /&gt;dybprop = acadBlock.GetDynamicBlockProperties&lt;BR /&gt;'For O = LBound(dybprop) To UBound(dybprop)&lt;BR /&gt;'If dybprop(O).PropertyName = "Distance8" Then dybprop(O).Value = .Range("I" &amp;amp; i).Value&lt;BR /&gt;'Add the block using the sheet data (insertion point, block name, scale factors and rotation angle).&lt;BR /&gt;'The 0.0174532925 is to convert degrees into radians.&lt;BR /&gt;Set acadBlock = acadDoc.ModelSpace.InsertBlock(InsertionPoint, BlockName, _&lt;BR /&gt;BlockScale.X, BlockScale.Y, BlockScale.Z, RotationAngle * 0.0174532925)&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;Next I&lt;BR /&gt;End With&lt;BR /&gt;Next O&lt;/P&gt;&lt;P&gt;'Zoom in to the drawing area.&lt;BR /&gt;acadApp.ZoomExtents&lt;/P&gt;&lt;P&gt;'Release the objects.&lt;BR /&gt;Set acadBlock = Nothing&lt;BR /&gt;Set acadDoc = Nothing&lt;BR /&gt;Set acadApp = Nothing&lt;BR /&gt;&lt;BR /&gt;'Inform the user about the process.&lt;BR /&gt;MsgBox "The blocks were successfully inserted in AutoCAD!", vbInformation, "Finished"&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;Sub ClearAll()&lt;BR /&gt;&lt;BR /&gt;Dim LastRow As Long&lt;BR /&gt;&lt;BR /&gt;'Find the last row and clear all the input data..&lt;BR /&gt;With Sheets("Coordinates")&lt;BR /&gt;.Activate&lt;BR /&gt;LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row&lt;BR /&gt;.Range("A2:H" &amp;amp; LastRow).ClearContents&lt;BR /&gt;.Range("A2").Select&lt;BR /&gt;End With&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 11:49:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/invalid-input/m-p/9075815#M10203</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-09T11:49:45Z</dc:date>
    </item>
  </channel>
</rss>

